{"record":{"id":"9106227c38fbaaa5","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-inval-910622","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Invalid specified variable name '%s', in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Invalid specified variable name '(.+?)', in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":23053,"sourceCode":"              pos = vector(arg1);\n              CImg<ulongT>::vector((ulongT)mp_vector_rand,pos,arg1,arg2,arg3,arg4,p2,arg5).move_to(code);\n              return_comp = true;\n              _cimg_mp_return(pos);\n            }\n\n            if (!std::strncmp(ss,\"ref(\",4)) { // Variable declaration\n              _cimg_mp_op(\"Function 'ref()'\");\n              s1 = ss4; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;\n              if (s1>=se1 || !*s1) compile(s1,s1,depth1,0,block_flags); // Will throw missing argument error\n              arg3 = compile(ss4,s1++,depth1,p_ref,block_flags|32);\n              *se1 = 0;\n\n              if (!cimg::is_varname(s1)) { // Invalid variable name\n                variable_name.assign(s1,(unsigned int)(se1 + 1 - s1)).back() = 0;\n                cimg::strellipsize(variable_name,64);\n                *se1 = ')';\n                _cimg_mp_strerr;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: %s: Invalid specified variable name '%s', \"\n                                            \"in expression '%s'.\",\n                                            pixel_type(),_cimg_mp_calling_function,s_op,\n                                            variable_name._data,s0);\n              }\n              get_variable_pos(s1,arg1,arg2);\n              if (arg2!=~0U) reserved_label[arg2] = arg3;\n              else if (arg1!=~0U) variable_pos[arg1] = arg3;\n              else { // New variable\n                if (variable_def._width>=variable_pos._width) variable_pos.resize(-200,1,1,1,0);\n                variable_pos[variable_def._width] = arg3;\n                CImg<char>::string(s1).move_to(variable_def);\n              }\n              if (is_vector(arg3))\n                set_reserved_vector(arg3); // Prevent from being used in further optimization\n              else if (is_comp_scalar(arg3)) memtype[arg3] = -1;\n              *se1 = ')';\n              _cimg_mp_return(arg3);","sourceCodeStart":23035,"sourceCodeEnd":23071,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L23035-L23071","documentation":"When parsing a variable declaration/assignment, the parser validates the identifier with cimg::is_varname(). If the token (e.g. starting with a digit, containing illegal characters, or being an empty/parenthesized fragment) is not a valid variable name, the error is thrown with the elided (max 64 chars) name.","triggerScenarios":"Assigning to an invalid identifier inside a math expression, e.g. '1abc = 5', 'my-var = 3', 'x$ = 2', or an empty name produced by a malformed expression like '(=)'.","commonSituations":"Typos in custom G'MIC commands, macro expansion inserting illegal characters into names, generated expressions from string concatenation producing malformed identifiers, or localization/encoding issues in variable names.","solutions":["Rename the variable so it starts with a letter/underscore and contains only alphanumerics/underscores","Print or inspect the expression string; a macro or string concatenation may be corrupting the name","Ensure the assignment target is non-empty (check for missing variable before '=')","Quote or restructure generated expressions so illegal characters do not leak into identifiers"],"exampleFix":"// before\n1st_val = 3;\n// after\nfirst_val = 3;","handlingStrategy":"validation","validationCode":"const isValidVarname = s => /^[A-Za-z_]\\w*$/.test(s);\nisValidVarname(name) || error('invalid variable name: ' + name);","typeGuard":null,"tryCatchPattern":"try { run(expr) } catch (CImgArgumentException &e) { log(e.what()); }","preventionTips":["Start identifiers with a letter or underscore","Avoid dashes, digits-first names and special characters","Sanitize generated expression strings before evaluation"],"tags":["cimg","math-parser","variable-name","identifier"],"backgroundTag":"invalid-identifier-format","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"}