{"record":{"id":"f0790363d0c12abe","repo":"Yalantis/uCrop","slug":"save-other-specified-filename-is-null","errorCode":null,"errorMessage":"save_other(): Specified filename is (null).","messagePattern":"save_other\\(\\): Specified filename is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":63881,"sourceCode":"      return *this;\n    }\n\n    // Save image for non natively supported formats.\n    /**\n       \\param filename Filename, as a C-string.\n       \\param quality Image quality (expressed in percent), when the file format supports it.\n       \\note\n       - The filename extension tells about the desired file format.\n       - This method tries to save the instance image as a file, using external tools from\n       <a href=\"http://www.imagemagick.org\">ImageMagick</a> or\n       <a href=\"http://www.graphicsmagick.org\">GraphicsMagick</a>.\n         At least one of these tool must be installed for the method to succeed.\n       - It is recommended to use the generic method save(const char*, int) const instead,\n         as it can handle some file formats natively.\n    **/\n    const CImg<T>& save_other(const char *const filename, const unsigned int quality=100) const {\n      if (!filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_other(): Specified filename is (null).\",\n                                    cimg_instance);\n      if (is_empty()) { cimg::fempty(0,filename); return *this; }\n      if (_depth>1)\n        cimg::warn(_cimg_instance\n                   \"save_other(): File '%s', saving a volumetric image with an external call to \"\n                   \"ImageMagick or GraphicsMagick only writes the first image slice.\",\n                   cimg_instance,filename);\n\n      const unsigned int omode = cimg::exception_mode();\n      bool is_saved = true;\n      cimg::exception_mode(0);\n      try { save_magick(filename); }\n      catch (CImgException&) {\n        try { save_imagemagick_external(filename,quality); }\n        catch (CImgException&) {\n          try { save_graphicsmagick_external(filename,quality); }\n          catch (CImgException&) {","sourceCodeStart":63863,"sourceCodeEnd":63899,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L63863-L63899","documentation":"CImg::save_other() is the catch-all saver that tries a sequence of external tools (ImageMagick, GraphicsMagick, medcon) for formats CImg does not support natively. A NULL filename is rejected up front with CImgArgumentException before any tool is attempted.","triggerScenarios":"Calling save_other(nullptr) or passing an uninitialized/NULL char* filename.","commonSituations":"Generic save wrappers that forward a user-supplied path which failed to resolve; config or CLI parsing that left the output path NULL.","solutions":["Check the filename for NULL before calling save_other().","Fix the upstream path resolution that returned NULL.","Default to a sensible output filename when none is provided.","Route through std::string and validate non-empty before .c_str()."],"exampleFix":"// before\nvoid saveImg(const CImg<float>& img, const char* p) { img.save_other(p); }\n// after\nvoid saveImg(const CImg<float>& img, const char* p) {\n  if (!p || !*p) p = \"output.png\";\n  img.save_other(p);\n}","handlingStrategy":"type-guard","validationCode":"if (!filename || !*filename) { filename = \"output.png\"; }","typeGuard":"bool validPath(const char* p) { return p != nullptr && *p != '\\0'; }","tryCatchPattern":"try {\n  img.save_other(filename);\n} catch (CImgArgumentException& e) {\n  std::fprintf(stderr, \"invalid filename: %s\", e.what());\n}","preventionTips":["Wrap save_other() in a helper that normalizes/validates the path first.","Resolve output paths once at startup and fail fast if absent.","Prefer std::string with default values over raw char* plumbing."],"tags":["null-pointer","argument-validation"],"backgroundTag":"null-argument","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}