{"record":{"id":"d5d70d3f61ec09f5","repo":"Yalantis/uCrop","slug":"load-pandore-file-size-lu-for-filename-s-do","errorCode":null,"errorMessage":"load_pandore(): File size %lu for filename '%s' does not match encoded image dimensions (%d,%d,%d,%d).","messagePattern":"load_pandore\\(\\): File size %lu for filename '(.+?)' does not match encoded image dimensions \\((.+?),(.+?),(.+?),(.+?)\\)\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":58817,"sourceCode":"      return CImg<T>().load_pandore(filename);\n    }\n\n    //! Load image from a PANDORE-5 file \\overloading.\n    CImg<T>& load_pandore(std::FILE *const file) {\n      return _load_pandore(file,0);\n    }\n\n    //! Load image from a PANDORE-5 file \\newinstance.\n    static CImg<T> get_load_pandore(std::FILE *const file) {\n      return CImg<T>().load_pandore(file);\n    }\n\n    CImg<T>& _load_pandore(std::FILE *const file, const char *const filename) {\n#define __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,ndim,stype) \\\n        cimg::fread(dims,nbdim,nfile); \\\n        if (endian) cimg::invert_endianness(dims,nbdim); \\\n        if ((ulongT)nwidth*nheight*ndepth*ndim>fsiz) \\\n          throw CImgIOException(_cimg_instance \\\n                                \"load_pandore(): File size %lu for filename '%s' does not match \"\\\n                                \"encoded image dimensions (%d,%d,%d,%d).\",\\\n                                cimg_instance,\\\n                                (long)fsiz,filename?filename:\"(FILE*)\",\\\n                                (int)nwidth,(int)nheight,(int)ndepth,(int)ndim); \\\n        assign(nwidth,nheight,ndepth,ndim); \\\n        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); } \\","sourceCodeStart":58799,"sourceCodeEnd":58835,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L58799-L58835","documentation":"_load_pandore() validates that the PANDORE file is large enough to actually contain the image dimensions declared in its header (width*height*depth*dim vs the file size). If the decoded dimensions imply more data than the file holds, CImg throws CImgIOException. This catches truncated or corrupt PANDORE files before out-of-bounds reads.","triggerScenarios":"Reading a truncated .pandore/.pan file; a header with wrong/garbled dimension fields; a file whose declared dims were modified or written by a buggy exporter.","commonSituations":"Incomplete downloads or interrupted copies; files created by a different/older PANDORE writer with mismatched header; corruption during transfer.","solutions":["Re-download or re-copy the file — it is most likely truncated","Verify the file size against the header dims yourself before loading","Re-export the file from the PANDORE tool with correct metadata","Check for disk/transfer corruption (checksum comparison with the original)"],"exampleFix":"// before\nimg.load_pandore(path); // throws on truncated file\n// after\nstruct stat st;\nif (stat(path, &st) != 0 || st.st_size < 32)\n  throw std::runtime_error(\"PANDORE file missing or too small\");\n// optionally sanity-check header dims vs st.st_size, then:\nimg.load_pandore(path);","handlingStrategy":"validation","validationCode":"struct stat st;\nif (stat(path,&st)!=0 || st.st_size < 32) throw std::runtime_error(\"file missing or truncated\");\n// optionally parse the header dims yourself and require dims product*sizeof <= st.st_size","typeGuard":null,"tryCatchPattern":"try { img.load_pandore(path); } catch (const cimg_library::CImgIOException &e) { /* size/dims mismatch = corrupt or truncated */ reject_file(path); }","preventionTips":["Verify file sizes/checksums after download or copy","Treat any load-time size/dimension mismatch as a corrupted-file signal, not a retry case","Keep the original export available for re-export"],"tags":["cimg","image-loading","pandore","corrupt-file"],"backgroundTag":"file-size-limit-exceeded","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"}