After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739457 - Some errors not detected for GIMP_PDB_COLOR arguments
Some errors not detected for GIMP_PDB_COLOR arguments
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Script-Fu
2.8.14
Other All
: Normal minor
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2014-10-31 16:40 UTC by saulgoode
Modified: 2014-11-30 17:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to type-check GIMP-PDB-COLOR arguments (2.05 KB, patch)
2014-10-31 16:40 UTC, saulgoode
none Details | Review

Description saulgoode 2014-10-31 16:40:47 UTC
Created attachment 289754 [details] [review]
Patch to type-check GIMP-PDB-COLOR arguments

Description:

When passing arguments of type GIMP_PDB_COLOR to PDB procedures (such as 'gimp-context-set-foreground'), the color specification should be either a string containing a CSS color or a list of three numbers (for the red, green, and blue components). Script-fu properly tests that the argument is either a string or a 3-element list but in the case of a list, it does not verify that the elements of the list are numbers. 


Steps to Reproduce:

  1) Open the Script-fu console
  2) Enter the command: 
    (gimp-context-set-foreground '(x y z))

Result:

  The foreground color gets set to white. Apparently the memory address of the symbols are treated as the list elements (and gets clamped to "255").

Expected result:

  Script-fu should detect that the list argument contains non-numbers and should generate an error.


Note:

  Current behavior does not interfere with proper functioning of valid scripts. It is only that errors that should be detected are not.

  Attached patch was made against GIMP 2.8.14. I am not sure if the error message sent during DEBUG_MARSHALL output is sufficient. It currently sends "COLOR list contains non-numbers" but does not echo the offending argument (to do so would require converting the Scheme expression to a string).
Comment 1 Michael Natterer 2014-11-30 17:35:07 UTC
Fixed in master and gimp-2-8. The patch contained tabs instead of
spaces, please try to avoid that.

commit dad54b67c1267db6b294004a5c2900a505558785
Author: Saul Goode <saul@crazyauntgail.com>
Date:   Fri Oct 31 12:13:07 2014 -0400

    Bug 739457 - Some errors not detected for GIMP_PDB_COLOR arguments
    
    Check that all 3 array elements are numbers-
    
    (cherry picked from commit d03b33f1d90991623fd1848c7a2d2a61900d4396)

 plug-ins/script-fu/scheme-wrapper.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)