[gtk/matthiasc/for-master: 3/6] cssshadowvalue: Handle error condition propertly




commit ea185cbdda48fea20d58863ed3ad7ff5add2ff6e
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 17 07:49:06 2021 -0400

    cssshadowvalue: Handle error condition propertly
    
    We were parsing off the end of our array before noticing
    that we've gone too far. gcc 11 warns about this.

 gtk/gtkcssshadowvalue.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 86dfcafdfb..94fccffd82 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -494,14 +494,14 @@ gtk_css_shadow_value_parse (GtkCssParser *parser,
     return gtk_css_shadow_value_new_none ();
 
   do {
-    if (gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows]))
-      n_shadows++;
-
-    if (n_shadows > MAX_SHADOWS)
+    if (n_shadows == MAX_SHADOWS)
       {
-        gtk_css_parser_error_syntax (parser, "Not more than 64 shadows supported");
+        gtk_css_parser_error_syntax (parser, "Not more than %d shadows supported", MAX_SHADOWS);
         goto fail;
       }
+    if (gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows]))
+      n_shadows++;
+
   } while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
 
   return gtk_css_shadow_value_new (shadows, n_shadows, FALSE);


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