[libgxps] lib: Fix potential NULL pointer dereference



commit 7e3bff93b880a420a3d96dd7272512a8ab547013
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Dec 20 19:41:18 2016 +0000

    lib: Fix potential NULL pointer dereference
    
    utf8 is dereferenced earlier in the function than the NULL check, so
    if it is NULL, this will crash. Move the length calculation lower down
    to avoid this.
    
    Coverity ID: 1391238
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776323

 libgxps/gxps-glyphs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libgxps/gxps-glyphs.c b/libgxps/gxps-glyphs.c
index d0c5154..87e234e 100644
--- a/libgxps/gxps-glyphs.c
+++ b/libgxps/gxps-glyphs.c
@@ -199,7 +199,6 @@ glyphs_lookup_index (cairo_scaled_font_t *scaled_font,
         cairo_glyph_t stack_glyphs[1];
         cairo_glyph_t *glyphs = stack_glyphs;
         int num_glyphs = 1;
-        int utf8_len = g_utf8_next_char (utf8) - utf8;
         gulong index = 0;
 
         if (utf8 == NULL || *utf8 == '\0')
@@ -207,7 +206,8 @@ glyphs_lookup_index (cairo_scaled_font_t *scaled_font,
 
         status = cairo_scaled_font_text_to_glyphs (scaled_font,
                                                    0, 0,
-                                                   utf8, utf8_len,
+                                                   utf8,
+                                                   g_utf8_next_char (utf8) - utf8,
                                                    &glyphs, &num_glyphs,
                                                    NULL, NULL, NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]