зеркало из https://github.com/microsoft/git.git
win32: plug memory leak on realloc() failure in syslog()
If realloc() fails then the original buffer is still valid. Free it before exiting the function. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
7234152e66
Коммит
149d8cbb2e
|
@ -43,8 +43,10 @@ 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) {
|
||||
free(oldstr);
|
||||
warning_errno("realloc failed");
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче