Skip to content

Commit db5b7c3

Browse files
committed
Merge branch 'js/ci-gcc-12-fixes'
Fixes real problems noticed by gcc 12 and works around false positives. * js/ci-gcc-12-fixes: dir.c: avoid "exceeds maximum object size" error with GCC v12.x nedmalloc: avoid new compile error compat/win32/syslog: fix use-after-realloc
2 parents 1bcf4f6 + 2acf4cf commit db5b7c3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

compat/nedmalloc/nedmalloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ static NOINLINE void RemoveCacheEntries(nedpool *p, threadcache *tc, unsigned in
323323
}
324324
static void DestroyCaches(nedpool *p) THROWSPEC
325325
{
326-
if(p->caches)
327326
{
328327
threadcache *tc;
329328
int n;

compat/win32/syslog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ void syslog(int priority, const char *fmt, ...)
4343
va_end(ap);
4444

4545
while ((pos = strstr(str, "%1")) != NULL) {
46+
size_t offset = pos - str;
4647
char *oldstr = str;
4748
str = realloc(str, st_add(++str_len, 1));
4849
if (!str) {
4950
free(oldstr);
5051
warning_errno("realloc failed");
5152
return;
5253
}
54+
pos = str + offset;
5355
memmove(pos + 2, pos + 1, strlen(pos));
5456
pos[1] = ' ';
5557
}

dir.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,6 +3137,15 @@ char *git_url_basename(const char *repo, int is_bundle, int is_bare)
31373137
end--;
31383138
}
31393139

3140+
/*
3141+
* It should not be possible to overflow `ptrdiff_t` by passing in an
3142+
* insanely long URL, but GCC does not know that and will complain
3143+
* without this check.
3144+
*/
3145+
if (end - start < 0)
3146+
die(_("No directory name could be guessed.\n"
3147+
"Please specify a directory on the command line"));
3148+
31403149
/*
31413150
* Strip trailing port number if we've got only a
31423151
* hostname (that is, there is no dir separator but a

0 commit comments

Comments
 (0)