[igt-dev] [PATCH i-g-t] resultgen: avoid null pointer dereference from realloc
Petri Latvala
petri.latvala at intel.com
Tue Dec 15 09:07:15 UTC 2020
On Tue, Dec 15, 2020 at 11:04:22AM +0200, Petri Latvala wrote:
> On Mon, Dec 14, 2020 at 04:10:24PM -0500, Jeremy Cline wrote:
> > realloc() and friends return NULL if they fail; simplify the
> > new_escaped_json_string() by allocating all the necessary memory
> > up-front and checking for a failed allocation.
> >
> > new_escaped_json_string() can already return NULL since
> > json_oject_new_string_len() returns NULL for various undocumented error
> > paths, and NULL is valid input for json_object_object_add(), which this
> > new_escaped_json_string() is currently exclusively used with. Thus,
> > returning NULL when memory allocation fails should be safe.
> >
> > Signed-off-by: Jeremy Cline <jcline at redhat.com>
>
> Nice cleanup, thanks.
>
> Reviewed-by: Petri Latvala <petri.latvala at intel.com>
And now merged.
--
Petri Latvala
More information about the igt-dev
mailing list