[gdk-pixbuf] io-xpm: Fix "format not a string literal" errors



commit d9e1980b2ff55f11cc6ba1cc9d8f813c60832915
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Jun 25 19:29:30 2016 +0200

    io-xpm: Fix "format not a string literal" errors
    
    With GCC 6.1 and newer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768042

 gdk-pixbuf/io-xpm.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c
index 596579a..9f72bc5 100644
--- a/gdk-pixbuf/io-xpm.c
+++ b/gdk-pixbuf/io-xpm.c
@@ -178,7 +178,6 @@ parse_color (const char *spec,
             XPMColor   *colorPtr)
 {
        if (spec[0] == '#') {
-               char fmt[16];
                int i, red, green, blue;
 
                if ((i = strlen (spec + 1)) % 3) {
@@ -186,25 +185,27 @@ parse_color (const char *spec,
                }
                i /= 3;
 
-               g_snprintf (fmt, 16, "%%%dx%%%dx%%%dx", i, i, i);
-
-               if (sscanf (spec + 1, fmt, &red, &green, &blue) != 3) {
-                       return FALSE;
-               }
                if (i == 4) {
+                       if (sscanf (spec + 1, "%4x%4x%4x", &red, &green, &blue) != 3)
+                               return FALSE;
                        colorPtr->red = red;
                        colorPtr->green = green;
                        colorPtr->blue = blue;
                } else if (i == 1) {
+                       if (sscanf (spec + 1, "%1x%1x%1x", &red, &green, &blue) != 3)
+                               return FALSE;
                        colorPtr->red = (red * 65535) / 15;
                        colorPtr->green = (green * 65535) / 15;
                        colorPtr->blue = (blue * 65535) / 15;
-               } else if (i == 2)
-               {
+               } else if (i == 2) {
+                       if (sscanf (spec + 1, "%2x%2x%2x", &red, &green, &blue) != 3)
+                               return FALSE;
                        colorPtr->red = (red * 65535) / 255;
                        colorPtr->green = (green * 65535) / 255;
                        colorPtr->blue = (blue * 65535) / 255;
                } else /* if (i == 3) */ {
+                       if (sscanf (spec + 1, "%3x%3x%3x", &red, &green, &blue) != 3)
+                               return FALSE;
                        colorPtr->red = (red * 65535) / 4095;
                        colorPtr->green = (green * 65535) / 4095;
                        colorPtr->blue = (blue * 65535) / 4095;


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