{"record":{"id":"ffb7ad6c93b203c8","repo":"Yalantis/uCrop","slug":"min-s","errorCode":null,"errorMessage":"min(): %s.","messagePattern":"min\\(\\): (.+?)\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":65536,"sourceCode":"    //-------------------------------------\n    //\n    //! \\name Mathematical Functions\n    //@{\n    //-------------------------------------\n\n    //! Return a reference to the minimum pixel value of the instance list.\n    /**\n    **/\n    T& min() {\n      bool is_all_empty = true;\n      T *ptr_min = 0;\n      cimglist_for(*this,l) if (!_data[l].is_empty()) {\n        ptr_min = _data[l]._data;\n        is_all_empty = false;\n        break;\n      }\n      if (is_all_empty)\n        throw CImgInstanceException(_cimglist_instance\n                                    \"min(): %s.\",\n                                    _data?\"List of empty images\":\"Empty instance\",\n                                    cimglist_instance);\n      T min_value = *ptr_min;\n      cimglist_for(*this,l) {\n        const CImg<T>& img = _data[l];\n        cimg_for(img,ptrs,T) if (*ptrs<min_value) min_value = *(ptr_min=ptrs);\n      }\n      return *ptr_min;\n    }\n\n    //! Return a reference to the minimum pixel value of the instance list \\const.\n    const T& min() const {\n      bool is_all_empty = true;\n      T *ptr_min = 0;\n      cimglist_for(*this,l) if (!_data[l].is_empty()) {\n        ptr_min = _data[l]._data;\n        is_all_empty = false;","sourceCodeStart":65518,"sourceCodeEnd":65554,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L65518-L65554","documentation":"CImgList<T>::min() computes the minimum pixel value across all images in the list. If every image in the list is empty (no pixel buffer) the scan finds no valid pointer and the library throws CImgInstanceException with \"min(): %s.\" where %s is \"List of empty images\" or \"Empty instance\" (ucrop/src/main/jni/CImg.h:65536). Min/max are undefined on no data, so the library refuses to return a bogus value.","triggerScenarios":"Calling the const/non-const min() on a CImgList where _data is null (empty list) or where every element CImg is empty (0-size dimensions), detected when the is_all_empty flag stays true after the cimglist_for scan.","commonSituations":"Computing statistics over a batch of images after all loads failed; a resizing/crop step that produced zero-sized images; calling min() on a default-constructed list used as an accumulator.","solutions":["Before calling min(), verify the list contains at least one non-empty image (loop and check !img.is_empty()).","Fix the upstream image loading/resizing so images actually contain pixels before statistics are computed.","Catch CImgInstanceException around the min() call and handle the empty-data case with a fallback value.","If the list is legitimately allowed to be empty, branch on is_empty() and skip the statistic entirely."],"exampleFix":"// before\nconst T mn = list.min();\n\n// after\nbool any = false;\nfor (unsigned int l = 0; l < list.size(); ++l) if (!list[l].is_empty()) { any = true; break; }\nif (!any) return; // or substitute a default\nconst T mn = list.min();","handlingStrategy":"validation","validationCode":"bool any = false; for (unsigned int l = 0; l < list.size(); ++l) if (!list[l].is_empty()) { any = true; break; } if (!any) { /* skip statistic */ }","typeGuard":"static inline bool hasNonEmptyImage(const CImgList<T>& l) { cimglist_for(l, i) if (!l[i].is_empty()) return true; return false; }","tryCatchPattern":"try { mn = list.min(); } catch (CImgInstanceException& e) { mn = defaultValue; }","preventionTips":["Guard all extremum/statistics calls with a non-empty-image check.","Fail loudly at load time so empty batches never reach analysis code.","Skip normalization steps when input data is absent rather than computing garbage extrema.","Log image counts/dimensions when building the list."],"tags":["cimg","jni","empty-instance","statistics"],"backgroundTag":"empty-result-set","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"}