Menu

#33 Preserve buffer on realloc failure

open
nobody
None
5
2026-06-17
2026-06-17
No

In expectv realloc() leaves the original allocation untouched when it fails. The current code assigns the return value directly to exp_buffer, losing the only local reference to the old allocation on ENOMEM.

Since cleanup stores exp_buffer back into f->buffer, the failure path also poisons the per-fd state with NULL while buffer_end and match_end may still refer to the old allocation.

Store the realloc() result in a temporary pointer and update exp_buffer only after success.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

1 Attachments

Discussion


Log in to post a comment.