From e59f35291fa5f97acfe408b7bce8652ec20566c8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 2 May 2006 11:36:41 -0700 Subject: [PATCH] atsui: Add missing check of return-value of malloc. This addresses the original problem noted in mozilla's bug #336129: Missing out-of-memory check at gfx/cairo/cairo/src/cairo-atsui-font.c:185 https://bugzilla.mozilla.org/show_bug.cgi?id=336129 This also adds a comment pointing out another malloc that is not checked, (but does not fix it). --- src/cairo-atsui-font.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c index 76b5a3c86..5e6079e5c 100644 --- a/src/cairo-atsui-font.c +++ b/src/cairo-atsui-font.c @@ -211,6 +211,8 @@ _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face, cairo_status_t status; font = malloc(sizeof(cairo_atsui_font_t)); + if (font == NULL) + return CAIRO_STATUS_NO_MEMORY; _cairo_scaled_font_init(&font->base, font_face, font_matrix, ctm, options, &cairo_atsui_scaled_font_backend); @@ -640,7 +642,11 @@ _cairo_atsui_font_old_show_glyphs (void *abstract_font, CGRect stack_rects[10]; CGRect *rects; int i; - + + /* XXX: Return-value of malloc needs to be checked for + * NULL. Can someone fix this who is more familiar with + * the cleanup needed in this function? + */ if (num_boxes > 10) rects = malloc (sizeof (CGRect) * num_boxes); else