{"record":{"id":"94d608c726c152d5","repo":"Yalantis/uCrop","slug":"load-gzip-external-specified-filename-is-null","errorCode":null,"errorMessage":"load_gzip_external(): Specified filename is (null) or does not exist.","messagePattern":"load_gzip_external\\(\\): Specified filename is \\(null\\) or does not exist\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":59715,"sourceCode":"#else\n      load_pnm(filename_tmp);\n#endif\n      std::remove(filename_tmp);\n      return *this;\n    }\n\n    //! Load image using GraphicsMagick's external tool 'gm' \\newinstance.\n    static CImg<T> get_load_graphicsmagick_external(const char *const filename) {\n      return CImg<T>().load_graphicsmagick_external(filename);\n    }\n\n    //! Load gzipped image file, using external tool 'gunzip'.\n    /**\n       \\param filename Filename, as a C-string.\n    **/\n    CImg<T>& load_gzip_external(const char *const filename) {\n      if (!filename || !cimg::is_file(filename))\n        throw CImgIOException(_cimg_instance\n                              \"load_gzip_external(): Specified filename is (null) or does not exist.\",\n                              cimg_instance);\n      CImg<charT> command(1024), filename_tmp(256), body(256);\n      const char\n        *const ext = cimg::split_filename(filename,body),\n        *const ext2 = cimg::split_filename(body,0);\n\n      do {\n        if (!cimg::strcasecmp(ext,\"gz\")) {\n          if (*ext2) cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s.%s\",\n                                   cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext2);\n          else cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s\",\n                             cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());\n        } else {\n          if (*ext) cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s.%s\",\n                                  cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext);\n          else cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s\",\n                             cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());","sourceCodeStart":59697,"sourceCodeEnd":59733,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L59697-L59733","documentation":"load_gzip_external() validates that filename is non-null and exists as a file via cimg::is_file(); otherwise it throws CImgIOException before invoking the external `gunzip` tool. Note this check throws CImgIOException (unlike the graphicsmagick variant which uses CImgArgumentException).","triggerScenarios":"Calling load_gzip_external(NULL), a non-existent path, a directory, or a dangling symlink.","commonSituations":"Assuming the .cimg/.gz file was decompressed elsewhere first; wrong relative path after a working-directory change; build pipeline not shipping the gz asset.","solutions":["Stat the path (or cimg::is_file) before calling and handle absence gracefully","Resolve to an absolute path from a known base directory","Fix upstream packaging/asset deployment so the gz file exists at runtime","If data is in memory, decompress with zlib directly instead of the external-tool loader"],"exampleFix":"// before\nimg.load_gzip_external(gzPath); // may not exist\n// after\nif (cimg::is_file(gzPath)) {\n  img.load_gzip_external(gzPath);\n} else {\n  cimg::dialog? // no; use:\n  throw std::runtime_error(\"gzip file missing: \" + std::string(gzPath));\n}","handlingStrategy":"validation","validationCode":"if (!gzPath || !cimg::is_file(gzPath)) {\n  throw std::runtime_error(\"gzip file missing before load_gzip_external\");\n}\nimg.load_gzip_external(gzPath);","typeGuard":"bool existing_file(const char* f) { return f != nullptr && cimg::is_file(f); }","tryCatchPattern":"try {\n  img.load_gzip_external(path);\n} catch (CImgIOException& e) {\n  if (!cimg::is_file(path)) rethrow; // precondition failure vs decode failure\n  // else handle decompression issue\n}","preventionTips":["Stat the .gz path before calling external-tool loaders","Ship/verify assets during packaging, not just at build time","Use absolute, config-anchored paths","Consider in-process zlib decompression to avoid external tools"],"tags":["cimg","gzip","file-not-found","external-tool"],"backgroundTag":"file-not-found","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"}