{"record":{"id":"687541f9ac1d4201","repo":"Yalantis/uCrop","slug":"load-pandore-specified-filename-is-null","errorCode":null,"errorMessage":"load_pandore(): Specified filename is (null).","messagePattern":"load_pandore\\(\\): Specified filename is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":58842,"sourceCode":"        const size_t siz = size(); \\\n        stype *buffer = new stype[siz]; \\\n        cimg::fread(buffer,siz,nfile); \\\n        if (endian) cimg::invert_endianness(buffer,siz); \\\n        T *ptrd = _data; \\\n        cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \\\n        buffer-=siz; \\\n        delete[] buffer\n\n#define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \\\n        if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \\\n        else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \\\n        else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \\\n        else throw CImgIOException(_cimg_instance \\\n                                   \"load_pandore(): Unknown pixel datatype in file '%s'.\", \\\n                                   cimg_instance, \\\n                                   filename?filename:\"(FILE*)\"); }\n      if (!file && !filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_pandore(): Specified filename is (null).\",\n                                    cimg_instance);\n\n      const ulongT fsiz = file?(ulongT)cimg_max_buf_size:(ulongT)cimg::fsize(filename);\n      std::FILE *const nfile = file?file:cimg::fopen(filename,\"rb\");\n      CImg<charT> header(32);\n      cimg::fread(header._data,12,nfile);\n      if (cimg::strncasecmp(\"PANDORE\",header,7)) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_pandore(): PANDORE header not found in file '%s'.\",\n                              cimg_instance,\n                              filename?filename:\"(FILE*)\");\n      }\n      unsigned int imageid, dims[8] = {};\n      int ptbuf[4] = {};\n      cimg::fread(&imageid,1,nfile);\n      const bool endian = imageid>255;","sourceCodeStart":58824,"sourceCodeEnd":58860,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L58824-L58860","documentation":"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.","triggerScenarios":"img.load_pandore(NULL) with no FILE*; passing a null result from getenv()/config lookup; a wrapper function forwarding an uninitialized path pointer.","commonSituations":"Unset environment variables; mis-typed config keys; null returns from path-resolution helpers; FFI layers converting absent strings to null.","solutions":["Validate the filename is non-null and non-empty before calling","Fix whatever supplier of the path returned null (env var, config key)","Ensure the FILE* variant is only used with a successfully opened stream"],"exampleFix":"// before\nimg.load_pandore(path);\n// after\nif (!path || !*path) throw std::invalid_argument(\"pandore path required\");\nimg.load_pandore(path);","handlingStrategy":"validation","validationCode":"if (!filename || !*filename) { throw std::invalid_argument(\"filename required for load_pandore\"); }","typeGuard":"bool is_valid_path(const char *p) { return p != nullptr && *p != '\\0'; }","tryCatchPattern":"try { img.load_pandore(path); } catch (const cimg_library::CImgArgumentException &e) { log(e.what()); }","preventionTips":["Guard all loader calls with a shared path-validation helper","Do not forward possibly-null pointers from config lookups directly into library calls","Initialize path variables at declaration to avoid uninitialized pointer forwarding"],"tags":["cimg","image-loading","pandore","null-argument"],"backgroundTag":"null-argument","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}