Yalantis/uCrop · warning
operator(): Invalid image request, at position [%u].
Error message
operator(): Invalid image request, at position [%u].
What it means
CImgList<T>::operator()(pos) returns the image at index pos in the list. When cimg_verbosity>=3 and pos is out of range (pos>=_width, the list size), it emits a warning and returns a reference to the first image (*_data) instead of crashing. This is a silent-wrong-result hazard: the caller gets image 0 rather than the requested one.
Solutions
- Check the index against list.size() before calling list(pos)
- Use cimglist_for or cimglist_forin to iterate instead of manual indices
- Verify the load actually produced the expected number of frames before accessing them (list.size() check)
- Enable bounds-checked debugging during development (cimg_verbosity>=3 makes this warn instead of silently returning _data)
Example fix
// before
CImg<unsigned char>& frame = frames(i);
// after
if (i < frames.size()) {
CImg<unsigned char>& frame = frames(i);
} else {
// handle missing frame
} Defensive patterns
Strategy: validation
Validate before calling
if (i >= 0 && (unsigned)i < frames.size()) { auto& img = frames(i); } else { /* handle */ } Type guard
bool inRange(const CImgList<T>& l, unsigned i) { return i < l.size(); } Prevention
- Check list.size() before indexed access
- Prefer cimglist_for iteration over manual indices
- Re-check size after any load/assign
When it happens
Trigger: Calling list(pos) with an index >= list.size(); iterating a list that was reassigned/emptied (assign()) while old indices are still used; passing a frame index from a failed load (e.g. load_yuv/load_tiff returned fewer frames than requested) into operator().
Common situations: Looping over frames after a partial video/YUV load, reusing stale indices after assign(), off-by-one loops (i<=list.size()), or sharing a CImgList between threads while one thread resizes it.
Related errors
- "[" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
- data(): Invalid pointer request, at position [%u].
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/c98c22e92a771bc8.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:64691
static const CImgList<T> _empty;
return _empty;
}
//@}
//------------------------------------------
//
//! \name Overloaded Operators
//@{
//------------------------------------------
//! Return a reference to one image element of the list.
/**
\param pos Index of the image element.
**/
CImg<T>& operator()(const unsigned int pos) {
#if cimg_verbosity>=3
if (pos>=_width) {
cimg::warn(_cimglist_instance
"operator(): Invalid image request, at position [%u].",
cimglist_instance,
pos);
return *_data;
}
#endif
return _data[pos];
}
//! Return a reference to one image of the list.
/**
\param pos Index of the image element.
**/
const CImg<T>& operator()(const unsigned int pos) const {
return const_cast<CImgList<T>*>(this)->operator()(pos);
}
//! Return a reference to one pixel value of one image of the list.View on GitHub (pinned to f788b534b4)