Skip to content

various: fix mishandling of failed `asprintf()` calls

Lyndon Brown requested to merge jnqnfe/vlc:invalid_frees into master

On allocation failure or error asprintf() returns -1 rather than a count of characters, and the pointer, in some implementations, is left in an undefined state.

This MR:

  • Fixes cases of reads and/or free() happening with such pointers when in such an undefined state.
  • In one case (lua) it's non-trivial to assess whether or not there is an existing misuse in the calling code that owns the pointer.
  • Fixes a few cases where inverted logic was causing the wrong success/failure paths to be taken.
  • Fixes a few cases where success / failure was being incorrectly determined through use of a ! based condition check.
Edited by Lyndon Brown

Merge request reports

Loading