Re: [PATCH] compat/win32: correct for incorrect compiler warning
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Jul 21, 2022, 14:17 UTC
- Message-ID
- <653c6a24-df30-2b06-4cf7-f01bd6012d55@gmail.com>
- In-Reply-To
- <pull.1294.git.1658256354725.gitgitgadget@gmail.com>
Hi Stolee
Show 11 quoted lines
> diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
> index 1f8d8934cc9..0af18d88825 100644
> --- a/compat/win32/syslog.c
> +++ b/compat/win32/syslog.c
> @@ -44,6 +44,7 @@ void syslog(int priority, const char *fmt, ...)
>
> while ((pos = strstr(str, "%1")) != NULL) {
> size_t offset = pos - str;
> + char *new_pos;
> char *oldstr = str;
> str = realloc(str, st_add(++str_len, 1));Not related to your patch but this context line looks suspicious as str_len is incremented without checking for overflow. I did wonder if it should be using a post increment instead and was using the st_add() to check if that overflowed but str_len is an int so we'd still have undefined behavior.
Best Wishes
Phillip