diff -r 0a5e583393e1 -r 51a084acef49 librazor/util.c --- a/librazor/util.c Tue Sep 09 15:27:12 2014 +0100 +++ b/librazor/util.c Fri Oct 17 10:08:28 2014 +0100 @@ -344,24 +344,6 @@ return concat; } -/** - * razor_path_add_root: - * - * Adds a root to a path. path must be an absolute pathname. In POSIX - * environments this is equivalent to the concationation of root and path. - * In Microsoft Windows an adjustment may need to be made for a drive letter - * in path (which will be dropped). - * - * Returns: The new pathname. - **/ -RAZOR_EXPORT char *razor_path_add_root(const char *path, const char *root) -{ - if (root && *root) - return razor_concat(root, SKIP_DRIVE_LETTER(path), NULL); - else - return strdup(path); -} - RAZOR_EXPORT const char *razor_system_arch(void) { #ifdef MSWIN_API @@ -394,12 +376,15 @@ int n; char *utf8; + if (len == 0) + return strdup(""); + n = WideCharToMultiByte(CP_UTF8, 0, utf16, len, NULL, 0, NULL, NULL); - if (len >= 0 && utf16[len]) + if (len > 0) n++; utf8 = malloc(n); (void)WideCharToMultiByte(CP_UTF8, 0, utf16, len, utf8, n, NULL, NULL); - if (len >= 0 && utf16[len]) + if (len > 0) utf8[n - 1] = 0; return utf8; @@ -410,12 +395,17 @@ int n; wchar_t *utf16; + if (len == 0) { + utf16 = calloc(1, sizeof(wchar_t)); + return utf16; + } + n = MultiByteToWideChar(CP_UTF8, 0, utf8, len, NULL, 0); - if (len >= 0 && utf8[len]) + if (len > 0) n++; utf16 = malloc(n * sizeof(wchar_t)); (void)MultiByteToWideChar(CP_UTF8, 0, utf8, len, utf16, n); - if (len >= 0 && utf8[len]) + if (len > 0) utf16[n - 1] = 0; return utf16;