mprintf: fix *dyn_vprintf() when out-of-memory

Follow-up to 0e48ac1f99a. Torture-testing 1455 would lead to a memory
leak otherwise.

Closes #9185
This commit is contained in:
Daniel Stenberg 2022-07-19 22:32:12 +02:00
parent 24694cb3ea
commit 7935972b37
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -1068,13 +1068,12 @@ extern int Curl_dyn_vprintf(struct dynbuf *dyn,
/* appends the formatted string, returns 0 on success, 1 on error */
int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save)
{
int retcode;
struct asprintf info;
info.b = dyn;
info.fail = 0;
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
if(!retcode && info.fail) {
(void)dprintf_formatf(&info, alloc_addbyter, format, ap_save);
if(info.fail) {
Curl_dyn_free(info.b);
return 1;
}