{"record":{"id":"1d0f47bd52fb27da","repo":"Yalantis/uCrop","slug":"load-jxl-specified-filename-is-null","errorCode":null,"errorMessage":"load_jxl(): Specified filename is (null).","messagePattern":"load_jxl\\(\\): Specified filename is \\(null\\)\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":57127,"sourceCode":"\n    //! Load image from a JPEG XL file \\newinstance.\n    static CImg<T> get_load_jxl(const char *const filename) {\n      return CImg<T>().load_jxl(filename);\n    }\n\n    //! Load image from a JPEG XL file \\overloading.\n    CImg<T>& load_jxl(std::FILE *const file) {\n      return _load_jxl(file,0);\n    }\n\n    //! Load image from a JPEG XL file \\newinstance.\n    static CImg<T> get_load_jxl(std::FILE *const file) {\n      return CImg<T>().load_jxl(file);\n    }\n\n    CImg<T>& _load_jxl(std::FILE *const file, const char *const filename) {\n      if (!file && !filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_jxl(): Specified filename is (null).\",\n                                    cimg_instance);\n\n#ifndef cimg_use_jxl\n      if (file)\n        throw CImgIOException(_cimg_instance\n                              \"load_jxl(): Unable to load data from '(FILE*)' unless libjxl is enabled.\",\n                              cimg_instance);\n      else return load_other(filename);\n#else\n      const char *nfilename = filename;\n      std::FILE *nfile = file?file:cimg::fopen(nfilename,\"rb\");\n      const long dataSize = cimg::fsize(nfile);\n      if (dataSize<=0) {\n        cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_jxl(): Failed to get file size '%s'.\",\n                              cimg_instance,","sourceCodeStart":57109,"sourceCodeEnd":57145,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L57109-L57145","documentation":"Raised by _load_jxl()'s guard when both the FILE* and the filename argument are null, i.e. no source for the JPEG XL image was provided ('(null)' is how the library reports the missing filename). It fires immediately, before the JXL decoder is invoked; supply a valid filename or an open FILE*.","triggerScenarios":"Calling load_jxl(NULL, NULL), or passing a null filename where a FILE* was expected to be opened earlier.","commonSituations":"Unchecked fopen failure, null path crossing a native/JNI boundary, uninitialized variables.","solutions":["Ensure the filename or FILE* is valid before calling load_jxl","Check fopen's return value before passing the handle","Verify path strings crossing JNI are non-null","Catch CImgArgumentException during development to catch call-site bugs"],"exampleFix":"// before\nstd::FILE* f = fopen(path,\"rb\");\nimg.load_jxl(f, path);\n// after\nif (!path) throw std::invalid_argument(\"jxl path is null\");\nstd::FILE* f = fopen(path,\"rb\");\nif (!f) throw std::runtime_error(\"cannot open jxl file\");\nimg.load_jxl(f, path);","handlingStrategy":"type-guard","validationCode":"if (!filename || !*filename) throw std::invalid_argument(\"filename required\");","typeGuard":"bool hasJxlSource(std::FILE* file, const char* filename) { return file != nullptr || (filename != nullptr && filename[0] != '\\0'); }","tryCatchPattern":"try { img.load_jxl(file, filename); }\ncatch (CImgArgumentException& e) { log(\"null jxl source: %s\", e.what()); }","preventionTips":["Check fopen results before passing handles","Validate paths at native boundaries","Initialize source pointers at declaration","Add unit tests covering null-source calls"],"tags":["jpeg-xl","image-loading","null-argument","cimg"],"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"}