diff -urN libxdg-basedir-1.1.1/src/basedir.c libxdg-basedir-1.1.1-haiku/src/basedir.c
--- libxdg-basedir-1.1.1/src/basedir.c	2010-07-13 05:48:54.053739520 +0000
+++ libxdg-basedir-1.1.1-haiku/src/basedir.c	2010-09-27 04:14:36.000000000 +0000
@@ -567,9 +567,9 @@
 	char *relhome;
 	if (!(relhome = xdgEnvDup(envname)) && errno != ENOMEM)
 	{
-		errno = 0;
 		const char *home;
 		unsigned int homelen;
+		errno = 0;
 		if (!(home = xdgGetEnv("HOME")))
 			return NULL;
 		if (!(relhome = (char*)malloc((homelen = strlen(home))+fallbacklength))) return NULL;
diff -urN libxdg-basedir-1.1.1/tests/testquery.c libxdg-basedir-1.1.1-haiku/tests/testquery.c
--- libxdg-basedir-1.1.1/tests/testquery.c	2010-07-13 05:48:54.050331648 +0000
+++ libxdg-basedir-1.1.1-haiku/tests/testquery.c	2010-09-27 04:17:53.000000000 +0000
@@ -49,6 +49,7 @@
 {
 	if (argc < 3)
 		return 1;
+	{
 	char *datatype = argv[1];
 	char *querytype = argv[2];
 	if (strcmp(datatype, "data") == 0)
@@ -87,4 +88,5 @@
 	else
 		return 1;
 	return 0;
+	}
 }
