{"record":{"id":"3ae11adb3bdbf405","repo":"Yalantis/uCrop","slug":"get-shared-images-specified-sub-list-indices","errorCode":null,"errorMessage":"get_shared_images(): Specified sub-list indices (%u->%u) are out of bounds.","messagePattern":"get_shared_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":66056,"sourceCode":"    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,\n                                    pos0,pos1);\n      CImgList<T> res(pos1 - pos0 + 1);\n      cimglist_for(res,l) res[l].assign(_data[pos0 + l],_data[pos0 + l]?true:false);\n      return res;\n    }\n\n    //! Return a shared sublist \\newinstance.\n    const CImgList<T> get_shared_images(const unsigned int pos0, const unsigned int pos1) const {\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,\n                                    pos0,pos1);\n      CImgList<T> res(pos1 - pos0 + 1);\n      cimglist_for(res,l) res[l].assign(_data[pos0 + l],_data[pos0 + l]?true:false);\n      return res;","sourceCodeStart":66038,"sourceCodeEnd":66074,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L66038-L66074","documentation":"The non-const CImgList::get_shared_images(pos0,pos1) throws the same range error as get_images: pos0 > pos1 or pos1 >= _width is rejected. Shared images alias the list's pixel buffers, so the indices must resolve to existing elements.","triggerScenarios":"list.get_shared_images(a,b) with a > b or b >= list.size(), e.g. requesting shared views 0..9 of a 4-image list.","commonSituations":"Creating shared views for in-place editing with stale size assumptions; slicing code shared with another container of different length.","solutions":["Clamp/validate indices: require pos0 <= pos1 < list.size() before the call","Check list.size() first and return an empty list when the range is invalid","Swap arguments if the order may be reversed"],"exampleFix":"// before\nCImgList<float> views = list.get_shared_images(2, 9); // throws if size < 10\n// after\nif (list.size() >= 10) {\n  CImgList<float> views = list.get_shared_images(2, 9);\n}","handlingStrategy":"validation","validationCode":"if (pos0 <= pos1 && pos1 < list.size()) { /* safe to request shared views */ }","typeGuard":null,"tryCatchPattern":"try { views = list.get_shared_images(pos0, pos1); } catch (const CImgArgumentException& e) { views = CImgList<T>(); }","preventionTips":["Validate indices before creating shared views","Keep shared-view creation next to the code that knows the list size","Prefer get_images (copies) when bounds are uncertain"],"tags":["cimg","index-out-of-range","shared-image","sublist"],"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"}