{"record":{"id":"7d802ed4131dcd90","repo":"Yalantis/uCrop","slug":"get-shared-points-invalid-request-of-a-shared-m","errorCode":null,"errorMessage":"get_shared_points(): Invalid request of a shared-memory subset (%u->%u,%u,%u,%u).","messagePattern":"get_shared_points\\(\\): Invalid request of a shared-memory subset \\(%u->%u,%u,%u,%u\\)\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":41567,"sourceCode":"        return (float)(*mp)(x,y,z,c);\n      }\n    };\n\n    //! Return a shared-memory image referencing a range of pixels of the image instance.\n    /**\n       \\param x0 X-coordinate of the starting pixel.\n       \\param x1 X-coordinate of the ending pixel.\n       \\param y0 Y-coordinate.\n       \\param z0 Z-coordinate.\n       \\param c0 C-coordinate.\n     **/\n    CImg<T> get_shared_points(const unsigned int x0, const unsigned int x1,\n                              const unsigned int y0=0, const unsigned int z0=0, const unsigned int c0=0) {\n      const ulongT\n        beg = (ulongT)offset(x0,y0,z0,c0),\n        end = (ulongT)offset(x1,y0,z0,c0);\n      if (beg>end || beg>=size() || end>=size())\n        throw CImgArgumentException(_cimg_instance\n                                    \"get_shared_points(): Invalid request of a shared-memory subset (%u->%u,%u,%u,%u).\",\n                                    cimg_instance,\n                                    x0,x1,y0,z0,c0);\n      return CImg<T>(_data + beg,x1 - x0 + 1,1,1,1,true);\n    }\n\n    //! Return a shared-memory image referencing a range of pixels of the image instance \\const.\n    const CImg<T> get_shared_points(const unsigned int x0, const unsigned int x1,\n                                    const unsigned int y0=0, const unsigned int z0=0, const unsigned int c0=0) const {\n      const ulongT\n        beg = (ulongT)offset(x0,y0,z0,c0),\n        end = (ulongT)offset(x1,y0,z0,c0);\n      if (beg>end || beg>=size() || end>=size())\n        throw CImgArgumentException(_cimg_instance\n                                    \"get_shared_points(): Invalid request of a shared-memory subset (%u->%u,%u,%u,%u).\",\n                                    cimg_instance,\n                                    x0,x1,y0,z0,c0);\n      return CImg<T>(_data + beg,x1 - x0 + 1,1,1,1,true);","sourceCodeStart":41549,"sourceCodeEnd":41585,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L41549-L41585","documentation":"CImg<T>::get_shared_points() returns a shared-memory 1D image referencing the pixels from x0 to x1 at (y0,z0,c0). It throws CImgArgumentException when the computed offsets are inconsistent or out of bounds: beg > end, beg >= size(), or end >= size() of the instance.","triggerScenarios":"Calling img.get_shared_points(x0,x1,...) with x0 > x1, or with x1 (or x0) so large that offset(x1,y0,z0,c0) exceeds the total number of pixels, e.g. x1 >= img.width().","commonSituations":"Off-by-one errors where the caller passes a count instead of an inclusive last index (x1 = width instead of width-1); copying code between images of different sizes; a resized image making previously valid indices out of range.","solutions":["Ensure x0 <= x1 and x1 < img.width() (indices are inclusive bounds).","Clamp the range before the call: x0 = std::min(x0, img.width()-1); x1 = std::min(x1, img.width()-1);","Verify y0/z0/c0 are within _height/_depth/_spectrum; a bad z0 or c0 also pushes the offset past size().","If the image may have been resized, recompute the valid range from img.width() at call time instead of caching indices."],"exampleFix":"// before\nCImg<float> row = img.get_shared_points(0, img.width());   // width, not width-1\n// after\nif (x1 >= img.width()) x1 = img.width() - 1;\nCImg<float> row = img.get_shared_points(0, x1, y, z, c);","handlingStrategy":"validation","validationCode":"bool ok = x0 <= x1 && x1 < img.width() && y0 < img.height() && z0 < img.depth() && c0 < img.spectrum();","typeGuard":null,"tryCatchPattern":"try { auto pts = img.get_shared_points(x0, x1, y, z, c); }\ncatch (CImgArgumentException& e) { /* clamp indices and retry or report range error */ }","preventionTips":["Remember x1 is an inclusive last index, not a count","Clamp indices against width/height/depth/spectrum before shared access","Recompute indices after any resize"],"tags":["cimg","shared-memory","bounds-check"],"backgroundTag":"index-out-of-bounds","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"}