[cairo-commit] src/cairo-font-options.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Jan 17 13:11:32 PST 2008


 src/cairo-font-options.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit b15e91d2b6c229dfe3da4a354306915cc42f75bd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 17 21:11:00 2008 +0000

    [cairo-font-options] Check for a NULL cairo_font_options_t
    
    On IRC Drakou reported a user error whereby cairo_scaled_font_create()
    was called with a NULL cairo_font_options_t. However, instead of
    reporting the error back to the user, cairo instead segfaulted trying
    to dereference the NULL pointer!
    
    Add a guard to check that the options is not NULL.

diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index c5d5c12..6b2cb08 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -161,7 +161,9 @@ slim_hidden_def (cairo_font_options_destroy);
 cairo_status_t
 cairo_font_options_status (cairo_font_options_t *options)
 {
-    if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
+    if (options == NULL)
+	return CAIRO_STATUS_NULL_POINTER;
+    else if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
 	return CAIRO_STATUS_NO_MEMORY;
     else
 	return CAIRO_STATUS_SUCCESS;


More information about the cairo-commit mailing list