Skip to content

Commit 4372a1f

Browse files
committed
Assert on OOM.
1 parent e9c9d71 commit 4372a1f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/bgfx.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,30 @@ namespace bgfx
217217
}
218218
#endif // BGFX_CONFIG_MEMORY_TRACKING
219219

220-
return ::malloc(_size);
220+
void* ptr = ::malloc(_size);
221+
BX_ASSERT(NULL != ptr, "Out of memory!");
222+
223+
return ptr;
221224
}
222225

223-
return bx::alignedAlloc(this, _size, _align, bx::Location(_file, _line) );
226+
void* ptr = bx::alignedAlloc(this, _size, _align, bx::Location(_file, _line) );
227+
BX_ASSERT(NULL != ptr, "Out of memory!");
228+
229+
return ptr;
224230
}
225231

226232
if (kNaturalAlignment >= _align)
227233
{
228-
return ::realloc(_ptr, _size);
234+
void* ptr = ::realloc(_ptr, _size);
235+
BX_ASSERT(NULL != ptr, "Out of memory!");
236+
237+
return ptr;
229238
}
230239

231-
return bx::alignedRealloc(this, _ptr, _size, _align, bx::Location(_file, _line) );
240+
void* ptr = bx::alignedRealloc(this, _ptr, _size, _align, bx::Location(_file, _line) );
241+
BX_ASSERT(NULL != ptr, "Out of memory!");
242+
243+
return ptr;
232244
}
233245

234246
void checkLeaks();

0 commit comments

Comments
 (0)