Skip to content

fix: check realloc return value in generateAircraftJson - #307

Open
zagers wants to merge 1 commit into
flightaware:masterfrom
zagers:fix/json-realloc-check
Open

fix: check realloc return value in generateAircraftJson#307
zagers wants to merge 1 commit into
flightaware:masterfrom
zagers:fix/json-realloc-check

Conversation

@zagers

@zagers zagers commented Jul 18, 2026

Copy link
Copy Markdown

Summary

Checks the return value of realloc in generateAircraftJson to prevent a NULL pointer dereference on out-of-memory conditions.

Changes

  • net_io.c: Save the old buffer pointer before realloc. If realloc returns NULL, free the old buffer and return NULL to the caller instead of crashing.

Motivation

When the JSON output buffer needs to grow, the code called realloc without checking the return value. If memory is exhausted, realloc returns NULL and the subsequent pointer assignments cause a segfault. This is more likely on memory-constrained devices or when tracking a very large number of aircraft.

Fixes #305

If realloc fails due to OOM, the code would dereference NULL. Now
saves the old buffer pointer and frees it on failure, returning NULL
to the caller.

Fixes flightaware#305
@mutability mutability added the LLM has LLM-generated content, treat with extreme suspicion label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM has LLM-generated content, treat with extreme suspicion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unchecked realloc in generateAircraftJson causes crash on OOM

2 participants