Merge branch 'jk/xdiff-clamp-funcname-context-index' into maint
[gitweb.git] / compat / win32 / syslog.c
index b905aea31bf53dc0f614d5e95c0dbd382818cbc4..161978d720aed9db5a00c77d1c6bd9a073544f15 100644 (file)
@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)
        va_end(ap);
 
        if (str_len < 0) {
-               warning("vsnprintf failed: '%s'", strerror(errno));
+               warning_errno("vsnprintf failed");
                return;
        }
 
        str = malloc(st_add(str_len, 1));
        if (!str) {
-               warning("malloc failed: '%s'", strerror(errno));
+               warning_errno("malloc failed");
                return;
        }
 
@@ -43,9 +43,11 @@ void syslog(int priority, const char *fmt, ...)
        va_end(ap);
 
        while ((pos = strstr(str, "%1")) != NULL) {
+               char *oldstr = str;
                str = realloc(str, st_add(++str_len, 1));
                if (!str) {
-                       warning("realloc failed: '%s'", strerror(errno));
+                       free(oldstr);
+                       warning_errno("realloc failed");
                        return;
                }
                memmove(pos + 2, pos + 1, strlen(pos));