Skip to content

Commit b8feb6e

Browse files
committed
Merge branch 'rs/win32-syslog-leakfix'
Memory leak in an error codepath has been plugged. * rs/win32-syslog-leakfix: win32: plug memory leak on realloc() failure in syslog()
2 parents 030e293 + 149d8cb commit b8feb6e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compat/win32/syslog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ void syslog(int priority, const char *fmt, ...)
4343
va_end(ap);
4444

4545
while ((pos = strstr(str, "%1")) != NULL) {
46+
char *oldstr = str;
4647
str = realloc(str, st_add(++str_len, 1));
4748
if (!str) {
49+
free(oldstr);
4850
warning_errno("realloc failed");
4951
return;
5052
}

0 commit comments

Comments
 (0)