mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-23 23:38:10 +02:00
[boilerplate/xmalloc] Special case malloc(0) and friends.
malloc(0) can return NULL so double check the requested size before exiting with an out-of-memory error.
This commit is contained in:
parent
56e505298c
commit
7332a5e994
2 changed files with 4 additions and 4 deletions
|
|
@ -36,7 +36,7 @@ xmalloc (size_t size)
|
|||
void *buf;
|
||||
|
||||
buf = malloc (size);
|
||||
if (!buf) {
|
||||
if (buf == NULL && size != 0) {
|
||||
CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ xcalloc (size_t nmemb, size_t size)
|
|||
void *buf;
|
||||
|
||||
buf = calloc (nmemb, size);
|
||||
if (!buf) {
|
||||
if (buf == NULL && nmemb != 0 && size != 0) {
|
||||
CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting\n");
|
||||
exit (1);
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ void *
|
|||
xrealloc (void *buf, size_t size)
|
||||
{
|
||||
buf = realloc (buf, size);
|
||||
if (!buf) {
|
||||
if (buf == NULL && size != 0) {
|
||||
CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting\n");
|
||||
exit (1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -922,7 +922,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op,
|
|||
}
|
||||
|
||||
/* Special case adding trapezoids onto a mask surface; we want to avoid
|
||||
* creating an intermediate temporary mask unecessarily.
|
||||
* creating an intermediate temporary mask unnecessarily.
|
||||
*
|
||||
* We make the assumption here that the portion of the trapezoids
|
||||
* contained within the surface is bounded by [dst_x,dst_y,width,height];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue