Yalantis/uCrop · error · CImgArgumentException

load_pandore(): Specified filename is (null).

Error message

load_pandore(): Specified filename is (null).

What it means

load_pandore() requires either an open FILE* or a non-null filename. When both are null, CImg throws CImgArgumentException before opening anything. It is an input-validation guard identical in spirit to the other CImg load_* null checks.

Source

Thrown at ucrop/src/main/jni/CImg.h:58842

        const size_t siz = size(); \
        stype *buffer = new stype[siz]; \
        cimg::fread(buffer,siz,nfile); \
        if (endian) cimg::invert_endianness(buffer,siz); \
        T *ptrd = _data; \
        cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \
        buffer-=siz; \
        delete[] buffer

#define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \
        if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \
        else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \
        else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \
        else throw CImgIOException(_cimg_instance \
                                   "load_pandore(): Unknown pixel datatype in file '%s'.", \
                                   cimg_instance, \
                                   filename?filename:"(FILE*)"); }
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "load_pandore(): Specified filename is (null).",
                                    cimg_instance);

      const ulongT fsiz = file?(ulongT)cimg_max_buf_size:(ulongT)cimg::fsize(filename);
      std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
      CImg<charT> header(32);
      cimg::fread(header._data,12,nfile);
      if (cimg::strncasecmp("PANDORE",header,7)) {
        if (!file) cimg::fclose(nfile);
        throw CImgIOException(_cimg_instance
                              "load_pandore(): PANDORE header not found in file '%s'.",
                              cimg_instance,
                              filename?filename:"(FILE*)");
      }
      unsigned int imageid, dims[8] = {};
      int ptbuf[4] = {};
      cimg::fread(&imageid,1,nfile);
      const bool endian = imageid>255;

View on GitHub (pinned to f788b534b4)

Solutions

  1. Validate the filename is non-null and non-empty before calling
  2. Fix whatever supplier of the path returned null (env var, config key)
  3. Ensure the FILE* variant is only used with a successfully opened stream

Example fix

// before
img.load_pandore(path);
// after
if (!path || !*path) throw std::invalid_argument("pandore path required");
img.load_pandore(path);
Defensive patterns

Strategy: validation

Validate before calling

if (!filename || !*filename) { throw std::invalid_argument("filename required for load_pandore"); }

Type guard

bool is_valid_path(const char *p) { return p != nullptr && *p != '\0'; }

Try / catch

try { img.load_pandore(path); } catch (const cimg_library::CImgArgumentException &e) { log(e.what()); }

Prevention

When it happens

Trigger: img.load_pandore(NULL) with no FILE*; passing a null result from getenv()/config lookup; a wrapper function forwarding an uninitialized path pointer.

Common situations: Unset environment variables; mis-typed config keys; null returns from path-resolution helpers; FFI layers converting absent strings to null.

Related errors


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/687541f9ac1d4201. Report an issue: GitHub.