[pango] pango-utils: Fix a potential strtol(NULL) call



commit 05f7dcda500e83e5cec87cc05e2ba2f8a6d28a8d
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Fri Nov 29 12:38:07 2013 +0000

    pango-utils: Fix a potential strtol(NULL) call
    
    parse_int() is called by pango_parse_enum(), which permits the enum
    string to be NULL. This string is passed directly through to parse_int()
    and then to strtol(), which is tagged as nonnull.
    
    Found by scan-build.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719549

 pango/pango-utils.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index b4ad451..3dfcebd 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -812,8 +812,14 @@ parse_int (const char *word,
           int        *out)
 {
   char *end;
-  long val = strtol (word, &end, 10);
-  int i = val;
+  long val;
+  int i;
+
+  if (word == NULL)
+    return FALSE;
+
+  val = strtol (word, &end, 10);
+  i = val;
 
   if (end != word && *end == '\0' && val >= 0 && val == i)
     {


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