diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-03-24 11:01:21 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-03-24 11:01:21 +0100 |
commit | ae60cf654a95ac5393fe8dfeeca59f874637af86 (patch) | |
tree | 49b8da293896436dcce08e38d25eb2b8ffc9731b | |
parent | 43edba2b8d25dd8e2290e1e4534b05387b0f60f9 (diff) |
Use dStrconcat() to concatenate strings
Reported-by: dogma
-rw-r--r-- | dpi/file.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -808,7 +808,7 @@ static char *File_normalize_path(const char *orig) str += 5; /* skip "file:" */ - Dstr *tmp = dStr_sized_new(32); + char *tmp = NULL; if (str[0] == '~' && (str[1] == '/' || str[1] == '\0')) { /* Expand home tilde "~" into "/home/userxyz" */ @@ -818,8 +818,7 @@ static char *File_normalize_path(const char *orig) char *next = str + 1; while (*next == '/') next++; - dStr_sprintf(tmp, "%s%s%s", home, sep, next); - str = tmp->str; + str = tmp = dStrconcat(home, sep, next, NULL); } else if (dStrnAsciiCasecmp(str, "//localhost/", 12) == 0) { /* Skip "//localhost" */ str += 11; @@ -837,7 +836,8 @@ static char *File_normalize_path(const char *orig) basename ? "/" : "", str); dFree(basename); - dStr_free(tmp, 1); + if (tmp) + dFree(tmp); /* Parse possible hexadecimal octets in the URI path */ for (i = 0; ds->str[i]; ++i) { |