{"record":{"id":"9971441c512cbced","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-function-997144","errorCode":null,"errorMessage":"\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': Invalid specified sprite geometry (%d,%d,%d,%d).\"","messagePattern":"\"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>: Function 'draw\\(\\)': Invalid specified sprite geometry \\((.+?),(.+?),(.+?),(.+?)\\)\\.\"","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":30172,"sourceCode":"          w = (int)_mp_arg(3), h = (int)_mp_arg(4), d = (int)_mp_arg(5), s = (int)_mp_arg(6),\n          x = (int)_mp_arg(9), y = (int)_mp_arg(10), z = (int)_mp_arg(11), c = (int)_mp_arg(12);\n        int dx = (int)mp.opcode[13], dy = (int)mp.opcode[14], dz = (int)mp.opcode[15], dc = (int)mp.opcode[16];\n        dx = (unsigned int)dx==~0U?w:(int)_mp_arg(13);\n        dy = (unsigned int)dy==~0U?h:(int)_mp_arg(14);\n        dz = (unsigned int)dz==~0U?d:(int)_mp_arg(15);\n        dc = (unsigned int)dc==~0U?s:(int)_mp_arg(16);\n\n        if (w<=0 || h<=0 || d<=0 || s<=0)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Invalid specified target vector geometry (%d,%d,%d,%d).\",\n                                      mp.imgin.pixel_type(),w,h,d,s);\n        if (sizD<(ulongT)w*h*d*s)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Target vector (%lu values) and its specified target geometry (%d,%d,%d,%d) \"\n                                      \"(%lu values) do not match.\",\n                                      mp.imgin.pixel_type(),sizD,w,h,d,s,(ulongT)w*h*d*s);\n        if (dx<=0 || dy<=0 || dz<=0 || dc<=0)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Invalid specified sprite geometry (%d,%d,%d,%d).\",\n                                      mp.imgin.pixel_type(),dx,dy,dz,dc);\n        if (sizS<(ulongT)dx*dy*dz*dc)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Sprite vector (%lu values) and its specified sprite geometry (%d,%d,%d,%d) \"\n                                      \"(%lu values) do not match.\",\n                                      mp.imgin.pixel_type(),sizS,dx,dy,dz,dc,(ulongT)dx*dy*dz*dc);\n\n        CImg<doubleT> D(ptrd,w,h,d,s,true);\n        const CImg<doubleT> S(ptrs,dx,dy,dz,dc,true);\n        const float opacity = (float)_mp_arg(17);\n\n        if (mp.opcode[18]!=~0U) { // Opacity mask specified\n          const ulongT sizM = mp.opcode[19];\n          if (sizM<(ulongT)dx*dy*dz)\n            throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                        \"Mask vector (%lu values) and specified sprite geometry (%u,%u,%u,%u) \"\n                                        \"(%lu values) do not match.\",","sourceCodeStart":30154,"sourceCodeEnd":30190,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L30154-L30190","documentation":"The math-parser 'draw()' opcode requires positive sprite (source) dimensions. When any of dx,dy,dz,dc passed to draw() is <= 0, the sprite geometry is meaningless and CImg throws CImgArgumentException before attempting to wrap the sprite vector.","triggerScenarios":"Calling draw(...) where the sprite geometry arguments dx, dy, dz or dc evaluate to zero or negative (e.g. variables resolved at runtime to 0).","commonSituations":"Dimension expressions computed from image properties that return 0 for empty images; off-by-one or wrong-variable arguments in formulas; user input supplying 0 for a channel count.","solutions":["Ensure all sprite geometry arguments dx,dy,dz,dc are >= 1","Check the expressions/variables feeding dx,dy,dz,dc for values that collapse to 0","Guard the draw() call so it only runs when the sprite image is non-empty"],"exampleFix":"// before\ndraw(ind,src,w0,h0,0,1,...); // dc = 0\n// after\ndraw(ind,src,w0,h0,d0,c0,...); // all dims >= 1","handlingStrategy":"validation","validationCode":"if (dx <= 0 || dy <= 0 || dz <= 0 || dc <= 0) { /* skip or fix geometry */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass literal 0 for any dimension","Validate runtime-computed dimensions before substituting into expressions","Check source image emptiness, since derived dims can be 0"],"tags":["cimg","image-processing","argument-validation","math-parser"],"backgroundTag":"invalid-argument-value","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}