{"record":{"id":"2a1c749e4c0fa209","repo":"Yalantis/uCrop","slug":"load-exr-specified-filename-is-null","errorCode":null,"errorMessage":"load_exr(): Specified filename is (null).","messagePattern":"load_exr\\(\\): Specified filename is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":58746,"sourceCode":"      _cimg_load_inr_case(1,1,64,double);\n      if (!loaded) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_inr(): Unknown pixel type defined in file '%s'.\",\n                              cimg_instance,\n                              filename?filename:\"(FILE*)\");\n      }\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Load image from a EXR file.\n    /**\n      \\param filename Filename, as a C-string.\n    **/\n    CImg<T>& load_exr(const char *const filename) {\n      if (!filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_exr(): Specified filename is (null).\",\n                                    cimg_instance);\n#if defined(cimg_use_openexr)\n      Imf::RgbaInputFile file(filename);\n      Imath::Box2i dw = file.dataWindow();\n      const int\n        inwidth = dw.max.x - dw.min.x + 1,\n        inheight = dw.max.y - dw.min.y + 1;\n      Imf::Array2D<Imf::Rgba> pixels;\n      pixels.resizeErase(inheight,inwidth);\n      file.setFrameBuffer(&pixels[0][0] - dw.min.x - dw.min.y*inwidth, 1, inwidth);\n      file.readPixels(dw.min.y, dw.max.y);\n      assign(inwidth,inheight,1,4);\n      T *ptr_r = data(0,0,0,0), *ptr_g = data(0,0,0,1), *ptr_b = data(0,0,0,2), *ptr_a = data(0,0,0,3);\n      cimg_forXY(*this,x,y) {\n        *(ptr_r++) = (T)pixels[y][x].r;\n        *(ptr_g++) = (T)pixels[y][x].g;\n        *(ptr_b++) = (T)pixels[y][x].b;","sourceCodeStart":58728,"sourceCodeEnd":58764,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L58728-L58764","documentation":"load_exr() loads OpenEXR images. It throws CImgArgumentException immediately if the filename pointer is null, before touching any EXR backend (OpenEXR or tinyexr). Like the other load_* null guards, it signals an API call with no input source.","triggerScenarios":"Calling img.load_exr(NULL) directly, or passing a lookup result (getenv, map find, config read) that returned null as the filename.","commonSituations":"Missing env var or config entry for the EXR path; a path-building function returned NULL on failure; FFI/bindings converting an empty optional to null.","solutions":["Null/empty-check the path before the call","Fix the source of the path (env var, config, API) so a real filename is produced","Use a non-EXR loader if the file is actually another format and the wrong loader was selected"],"exampleFix":"// before\nimg.load_exr(config.get(\"exr_path\")); // may be NULL\n// after\nconst char *p = config.get(\"exr_path\");\nif (!p) throw std::runtime_error(\"exr_path not configured\");\nimg.load_exr(p);","handlingStrategy":"validation","validationCode":"if (!filename || !*filename) { throw std::invalid_argument(\"filename required for load_exr\"); }","typeGuard":"bool is_valid_path(const char *p) { return p != nullptr && *p != '\\0'; }","tryCatchPattern":"try { img.load_exr(path); } catch (const cimg_library::CImgArgumentException &e) { log(e.what()); }","preventionTips":["Validate all paths at the boundary where they enter your code","Fail fast on missing config/env values instead of forwarding null","Use typed path wrappers (std::filesystem::path) and check !empty() before c_str()"],"tags":["cimg","image-loading","exr","null-argument"],"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"}