From: Junio C Hamano Date: Tue, 24 May 2022 20:58:38 GMT Subject: Re: [PATCH 1/4] compat/win32/syslog: fix use-after-realloc Message-ID: In-Reply-To: Johannes Schindelin writes: >> 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 ;-) >> @@ -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.