Skip to content

enhancement; validate reference argument of gimp_scanner_parse_string before using it

Ghost User requested to merge (removed):master into master

Our team studies historical log evolution of gimp, and found several similar patches which all validate the reference argument of gimp_scanner_parse_string before using it.

Based on this finding, we modify one missed spot. Thanks for your time on reading our post, and we are looking forward to your reply about the feasibility of our modification.

Two of the historical log revisions are listed as follows:

  • /second/src/sample/gimp/versions/gimp-2.10.2/app/core/gimptoolpreset.c
       if (! gimp_scanner_parse_string (scanner, &type_name))
           {
             *expected = G_TOKEN_STRING;
             break;
           }
 
+        if (! (type_name && *type_name))
+          {
+            g_scanner_error (scanner, "GimpToolOptions type name is empty");
+            *expected = G_TOKEN_NONE;
+            g_free (type_name);
+            break;
+          }
  • /second/src/sample/gimp/versions/gimp-2.10.2/app/plug-in/plug-in-rc.c
 if (! gimp_scanner_parse_string (scanner, &str))
     return G_TOKEN_STRING;
 
+  if (! (str && *str))
+    {
+      g_scanner_error (scanner, "procedure name is empty");
+      return G_TOKEN_ERROR;
+    }
+
Edited by Ghost User

Merge request reports