Work around i386 ASAN null pointer bug

For some reason, i386 ASAN does not copy a pointer somewhere in the
code. Using gdb I get a mention of a synthetic pointer, so perhaps
the compiler instrumented with ASAN thinks this pointer isn't
used. Anyway, commit adds a check for that null pointer which
isn't necessary otherwise and is only activated for i386 ASAN.

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=58524
This commit is contained in:
Martijn van Beurden 2024-07-25 11:31:36 +02:00
parent 215d1aa633
commit 33b9a4a765
1 changed files with 6 additions and 0 deletions

View File

@ -1635,6 +1635,12 @@ static void static_metadata_clear(static_metadata_t *m)
static FLAC__bool static_metadata_append(static_metadata_t *m, FLAC__StreamMetadata *d, FLAC__bool needs_delete) static FLAC__bool static_metadata_append(static_metadata_t *m, FLAC__StreamMetadata *d, FLAC__bool needs_delete)
{ {
void *x; void *x;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#ifdef __i386__
/* Work around i386 ASAN bug */
if(0 == d) return true;
#endif
#endif
if(0 == (x = safe_realloc_nofree_muladd2_(m->metadata, sizeof(*m->metadata), /*times (*/m->num_metadata, /*+*/1/*)*/))) if(0 == (x = safe_realloc_nofree_muladd2_(m->metadata, sizeof(*m->metadata), /*times (*/m->num_metadata, /*+*/1/*)*/)))
return false; return false;
m->metadata = (FLAC__StreamMetadata**)x; m->metadata = (FLAC__StreamMetadata**)x;