If the string was non-NULL but empty (str="\0"), the following \0 assignment
would write to str[-1] and thus cause memory corruption.
On PPC and MIPS, this was causing crashes in glibc.
closedir(dir);
str = g_string_free(result, FALSE);
closedir(dir);
str = g_string_free(result, FALSE);
+ if (str && str[0] != '\0') {
+ /*
+ * Remove the trailing separator so that services doesn't end up
+ * with an empty element.
+ */
str[strlen(str) - 1] = '\0';
services = g_strsplit(str, "/", -1);
}
str[strlen(str) - 1] = '\0';
services = g_strsplit(str, "/", -1);
}