Re: [PATCH 1/4] compat/win32/syslog: fix use-after-realloc
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 24, 2022, 20:58 UTC
- Message-ID
- <xmqqy1yqfy0x.fsf@gitster.g>
- In-Reply-To
- <nycvar.QRO.7.76.6.2205241431400.352@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
>> str = realloc(str, st_add(++str_len, 1)); > > Since it has been raised elsewhere: Why is that `++str_len` not turned > into an `st_add()`? > ... > Now you know,
I'd be more worried about a macro looking thing evalutating its parameters more than once, though. But unlike st_addN(), st_add() is an inline function so we do not have to worry about that ;-)
Show 5 quoted lines
>> @@ -50,6 +51,7 @@ void syslog(int priority, const char *fmt, ...)
>> warning_errno("realloc failed");
>> return;
>> }
>> + pos = str + offset;The adjustment using ofs is very much straight-forward. Nicely spotted and nicely corrected.
Thanks.