{"record":{"id":"59258e0c540acc40","repo":"Yalantis/uCrop","slug":"save-gzip-external-specified-filename-is-null","errorCode":null,"errorMessage":"save_gzip_external(): Specified filename is (null).","messagePattern":"save_gzip_external\\(\\): Specified filename is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":63661,"sourceCode":"                                    cimg_instance);\n      if (is_empty()) { cimg::fempty(0,filename); return *this; }\n\n      CImgList<T> list;\n      get_split('z').move_to(list);\n      list.save_ffmpeg_external(filename,fps,codec,bitrate);\n      return *this;\n    }\n\n    //! Save image using gzip external binary.\n    /**\n       \\param filename Filename, as a C-string.\n       \\note This method uses \\c gzip, an external executable binary provided by\n         <a href=\"//http://www.gzip.org\">gzip</a>.\n       It must be installed for the method to succeed.\n    **/\n    const CImg<T>& save_gzip_external(const char *const filename) const {\n      if (!filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_gzip_external(): Specified filename is (null).\",\n                                    cimg_instance);\n      if (is_empty()) { cimg::fempty(0,filename); return *this; }\n\n      CImg<charT> command(1024), filename_tmp(256), body(256);\n      const char\n        *ext = cimg::split_filename(filename,body),\n        *ext2 = cimg::split_filename(body,0);\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.cimg\",\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.cimg\",","sourceCodeStart":63643,"sourceCodeEnd":63679,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L63643-L63679","documentation":"save_gzip_external() compresses the image by invoking the external gzip executable on a temporary file, redirecting output to the given filename. A null filename gives nothing to write to, so it throws CImgArgumentException immediately. gzip must be installed for the method to succeed.","triggerScenarios":"Calling save_gzip_external(NULL) or with a filename variable that is null (defaulted char* never assigned).","commonSituations":"Downstream of a failed path resolution; portable code paths where filename construction was skipped; calling it on Windows without gzip installed (the null check fires first, missing-gzip surfaces later as a different error).","solutions":["Pass a concrete filename, e.g. img.save_gzip_external(\"out.cimg.gz\").","Default the path if null before calling.","Consider cimg-library's built-in gzip support or zlib-based saving if external tools are undesirable."],"exampleFix":"// before\nimg.save_gzip_external(path); // path may be NULL\n// after\nimg.save_gzip_external(path ? path : \"image.cimg.gz\");","handlingStrategy":"validation","validationCode":"if (!fname || !*fname) fname = \"image.cimg.gz\";\nimg.save_gzip_external(fname);","typeGuard":"bool validPath(const char *p) { return p != nullptr && p[0] != '\\0'; }","tryCatchPattern":"try { img.save_gzip_external(path.c_str()); }\ncatch (cimg_library::CImgArgumentException &e) { std::fprintf(stderr, \"gzip save: %s\\n\", e.what()); }","preventionTips":["Check the filename for null/emptiness before external saves.","Verify gzip presence (cimg::gzip_path()) when targeting constrained environments.","Prefer built-in formats where external binaries are risky."],"tags":["cimg","null-argument","gzip","external-tool","compression"],"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"}