[repacker] Fix fuzzer memory leak.

https://oss-fuzz.com/testcase-detail/6419865171525632
This commit is contained in:
Garret Rieger 2023-05-26 23:04:25 +00:00 committed by Behdad Esfahbod
parent 5abe713203
commit 20c564bc76
4 changed files with 9 additions and 4 deletions

View file

@ -401,9 +401,10 @@ struct graph_t
return vertices_[i].obj;
}
void add_buffer (char* buffer)
bool add_buffer (char* buffer)
{
buffers.push (buffer);
return !buffers.in_error ();
}
/*

View file

@ -52,7 +52,11 @@ unsigned gsubgpos_graph_context_t::create_node (unsigned size)
if (!buffer)
return -1;
add_buffer (buffer);
if (!add_buffer (buffer)) {
// Allocation did not get stored for freeing later.
hb_free (buffer);
return -1;
}
return graph.new_node (buffer, buffer + size);
}

View file

@ -47,9 +47,9 @@ struct gsubgpos_graph_context_t
HB_INTERNAL unsigned create_node (unsigned size);
void add_buffer (char* buffer)
bool add_buffer (char* buffer)
{
graph.add_buffer (buffer);
return graph.add_buffer (buffer);
}
private: