mirror of
https://github.com/moparisthebest/curl
synced 2025-03-01 01:41:50 -05:00
strerror: fix null deref on winapi out-of-memory
Follow-up to bed5f84 from several days ago. Ref: https://github.com/curl/curl/pull/6005
This commit is contained in:
parent
7920be9473
commit
9a13f7c2a7
@ -670,9 +670,11 @@ get_winapi_error(int err, char *buf, size_t buflen)
|
|||||||
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
|
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
|
||||||
LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(TCHAR), NULL)) {
|
LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(TCHAR), NULL)) {
|
||||||
char *msg = curlx_convert_tchar_to_UTF8(wbuf);
|
char *msg = curlx_convert_tchar_to_UTF8(wbuf);
|
||||||
strncpy(buf, msg, buflen - 1);
|
if(msg) {
|
||||||
buf[buflen-1] = '\0';
|
strncpy(buf, msg, buflen - 1);
|
||||||
curlx_unicodefree(msg);
|
buf[buflen-1] = '\0';
|
||||||
|
curlx_unicodefree(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user