{"record":{"id":"22fe3240b418f639","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-s-22fe32","errorCode":null,"errorMessage":"[\" cimg_appname \"_math_parser] CImg<%s>::%s: %s%s Image list cannot be empty, for expression '%s'.","messagePattern":"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>::(.+?): (.+?)(.+?) Image list cannot be empty, for expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":25267,"sourceCode":"            else cimg_snprintf(sb_type,sb_type._width,\"'scalar' or 'vector'\");\n          }\n          char *s0;\n          _cimg_mp_strerr;\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                      \"CImg<%s>::%s: %s%s %s%s has invalid type '%s' (should be %s), \"\n                                      \"in expression '%s'.\",\n                                      pixel_type(),_cimg_mp_calling_function,s_op,*s_op?\":\":\"\",\n                                      s_arg,*s_op=='F'?(*s_arg?\" argument\":\" Argument\"):(*s_arg?\" operand\":\" Operand\"),\n                                      s_type(arg)._data,sb_type._data,s0);\n        }\n      }\n\n      // Check that imglist are not empty.\n      void check_list(char *const ss, char *const se, const char saved_char) {\n        if (!imglist) {\n          char *s0;\n          _cimg_mp_strerr;\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                      \"CImg<%s>::%s: %s%s Image list cannot be empty, for expression '%s'.\",\n                                      pixel_type(),_cimg_mp_calling_function,s_op,*s_op?\":\":\"\",s0);\n        }\n      }\n\n      static void mp_check_list(_cimg_math_parser& mp, const char *const funcname) {\n        if (!mp.imglist)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                      \"CImg<%s>: Function '%s()': Images list cannot be empty.\",\n                                      pixel_type(),funcname);\n      }\n\n      // Insert constant value in memory.\n      unsigned int const_scalar(const double val) {\n\n        // Search for built-in constant.\n        if (cimg::type<double>::is_nan(val)) return _cimg_mp_slot_nan;\n        if (val==(double)(int)val) {","sourceCodeStart":25249,"sourceCodeEnd":25285,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L25249-L25285","documentation":"The math parser helper check_list throws when an expression function that operates on the image list (e.g. dynamic-array functions) is invoked while the parser's imglist is empty. CImg needs at least one image in the list to execute such functions. This prevents out-of-bounds access to a non-existent image slot.","triggerScenarios":"Calling a function like 'da_at(...)' or other image-list-dependent MP functions inside fill()/expression on a default-constructed or empty CImgList, or an expression evaluated without assigning images.","commonSituations":"Invoking expression functions on a CImg that has never been assigned data; passing an empty CImgList to the math parser; chaining operations after a failed load left the list empty.","solutions":["Ensure the CImg/CImgList is assigned (non-empty) before evaluating the expression.","Check that the image file load succeeded before running fill()/expression.","Use an expression that does not require the image list if no images are needed.","Guard with if (!img.is_empty()) before evaluating."],"exampleFix":"// before\nCImg<float> img; // empty\nimg.fill(\"da_at(I,0)\");\n// after\nCImg<float> img(w,h,1,1,0);\nimg.fill(\"da_at(I,0)\");","handlingStrategy":"validation","validationCode":"if (img.is_empty()) throw std::runtime_error(\"image must be assigned before expression evaluation\");","typeGuard":"bool usable(const CImg<T>& im) { return !im.is_empty() && im.width() > 0; }","tryCatchPattern":"try { img.fill(expr); } catch (const cimg_library::CImgArgumentException& e) { /* assign image or skip */ }","preventionTips":["Always assign/construct images before fill()","Check load() return state","Skip list-dependent functions when no images exist"],"tags":["cimg","math-parser","empty-image-list"],"backgroundTag":"empty-required-field","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}