This commit is contained in:
Garret Rieger 2021-03-31 11:23:46 -07:00 committed by Behdad Esfahbod
parent bd2950b393
commit c5c13006a1
3 changed files with 7 additions and 1 deletions

View File

@ -147,6 +147,7 @@ struct graph_t
} }
vertex_t* v = vertices_.push (); vertex_t* v = vertices_.push ();
if (check_success (!vertices_.in_error ()))
v->obj = *objects[i]; v->obj = *objects[i];
if (!removed_nil) continue; if (!removed_nil) continue;
for (unsigned i = 0; i < v->obj.links.length; i++) for (unsigned i = 0; i < v->obj.links.length; i++)

View File

@ -177,6 +177,11 @@ struct hb_vector_t
Type *push (T&& v) Type *push (T&& v)
{ {
Type *p = push (); Type *p = push ();
if (p == &Crap (Type))
// If push failed to allocate then don't copy v, since this may cause
// the created copy to leak memory since we won't have stored a
// reference to it.
return p;
*p = hb_forward<T> (v); *p = hb_forward<T> (v);
return p; return p;
} }