{"record":{"id":"b045f49a1642ee27","repo":"Yalantis/uCrop","slug":"images-specified-sub-list-indices-u-u-are","errorCode":null,"errorMessage":"images(): Specified sub-list indices (%u->%u) are out of bounds.","messagePattern":"images\\(\\): Specified sub-list indices \\(%u->%u\\) are out of bounds\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":66040,"sourceCode":"\n    //! Reverse list order \\newinstance.\n    CImgList<T> get_reverse() const {\n      return (+*this).reverse();\n    }\n\n    //! Return a sublist.\n    /**\n      \\param pos0 Starting index of the sublist.\n      \\param pos1 Ending index of the sublist.\n    **/\n    CImgList<T>& images(const unsigned int pos0, const unsigned int pos1) {\n      return get_images(pos0,pos1).move_to(*this);\n    }\n\n    //! Return a sublist \\newinstance.\n    CImgList<T> get_images(const unsigned int pos0, const unsigned int pos1) const {\n      if (pos0>pos1 || pos1>=_width)\n        throw CImgArgumentException(_cimglist_instance\n                                    \"images(): Specified sub-list indices (%u->%u) are out of bounds.\",\n                                    cimglist_instance,\n                                    pos0,pos1);\n      CImgList<T> res(pos1 - pos0 + 1);\n      cimglist_for(res,l) res[l].assign(_data[pos0 + l]);\n      return res;\n    }\n\n    //! Return a shared sublist.\n    /**\n      \\param pos0 Starting index of the sublist.\n      \\param pos1 Ending index of the sublist.\n    **/\n    CImgList<T> get_shared_images(const unsigned int pos0, const unsigned int pos1) {\n      if (pos0>pos1 || pos1>=_width)\n        throw CImgArgumentException(_cimglist_instance\n                                    \"get_shared_images(): Specified sub-list indices (%u->%u) are out of bounds.\",\n                                    cimglist_instance,","sourceCodeStart":66022,"sourceCodeEnd":66058,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L66022-L66058","documentation":"CImgList::get_images(pos0,pos1) returns a copy sublist and throws when pos0 > pos1 or pos1 >= _width, i.e. the requested index range is empty, reversed, or extends past the end of the list. The indices must satisfy pos0 <= pos1 < size().","triggerScenarios":"list.get_images(3,1) (reversed order), list.get_images(0,10) on a 5-element list, or slicing an empty list.","commonSituations":"Python-style slicing habits where reversed ranges yield empty results; end index computed as start+count instead of start+count-1; slicing after the list was resized smaller.","solutions":["Validate pos0 <= pos1 and pos1 < list.size() before calling, or clamp both","If order may be reversed, swap pos0/pos1 first","Check that the list is non-empty and large enough for the desired slice"],"exampleFix":"// before\nCImgList<float> sub = list.get_images(0, 10); // throws if size < 11\n// after\nconst unsigned int end = std::min(10u, list.size() - 1);\nCImgList<float> sub = list.size() ? list.get_images(0, end) : CImgList<float>();","handlingStrategy":"validation","validationCode":"bool valid = pos0 <= pos1 && !list.is_empty() && pos1 < list.size();","typeGuard":null,"tryCatchPattern":"try { sub = list.get_images(pos0, pos1); } catch (const CImgArgumentException& e) { sub = CImgList<T>(); }","preventionTips":["Remember CImg ranges are inclusive, not end-exclusive","Swap arguments if order may be reversed","Guard slices after any resize/assign that shrinks the list"],"tags":["cimg","index-out-of-range","sublist","argument-validation"],"backgroundTag":"index-out-of-range","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}