{"record":{"id":"81a7e2b4adf581d7","repo":"Yalantis/uCrop","slug":"load-dlm-specified-filename-is-null","errorCode":null,"errorMessage":"load_dlm(): Specified filename is (null).","messagePattern":"load_dlm\\(\\): Specified filename is \\(null\\)\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":56716,"sourceCode":"\n    //! Load image from a DLM file \\newinstance.\n    static CImg<T> get_load_dlm(const char *const filename) {\n      return CImg<T>().load_dlm(filename);\n    }\n\n    //! Load image from a DLM file \\overloading.\n    CImg<T>& load_dlm(std::FILE *const file) {\n      return _load_dlm(file,0);\n    }\n\n    //! Load image from a DLM file \\newinstance.\n    static CImg<T> get_load_dlm(std::FILE *const file) {\n      return CImg<T>().load_dlm(file);\n    }\n\n    CImg<T>& _load_dlm(std::FILE *const file, const char *const filename) {\n      if (!file && !filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_dlm(): Specified filename is (null).\",\n                                    cimg_instance);\n\n      std::FILE *const nfile = file?file:cimg::fopen(filename,\"r\");\n      CImg<charT> delimiter(256), tmp(256); *delimiter = *tmp = 0;\n      unsigned int cdx = 0, dx = 0, dy = 0;\n      int err = 0;\n      double val;\n      assign(256,256,1,1,(T)0);\n      while ((err = std::fscanf(nfile,\"%lf%255[^0-9eEinfa.+-]\",&val,delimiter._data))>0) {\n        if (err>0) (*this)(cdx++,dy) = (T)val;\n        if (cdx>=_width) resize(3*_width/2,_height,1,1,0);\n        char c = 0;\n        if (!cimg_sscanf(delimiter,\"%255[^\\n]%c\",tmp._data,&c) || c=='\\n') {\n          dx = std::max(cdx,dx);\n          if (++dy>=_height) resize(_width,3*_height/2,1,1,0);\n          cdx = 0;\n        }","sourceCodeStart":56698,"sourceCodeEnd":56734,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L56698-L56734","documentation":"CImg<T>::load_dlm() needs either an open std::FILE* or a non-null filename; both being null throws CImgArgumentException immediately. DLM is the delimiter-separated values loader, and there is nothing to parse without a source.","triggerScenarios":"Calling load_dlm(nullptr) or the dispatch overload where both file and filename are NULL, typically from an unset path variable.","commonSituations":"Forwarding an optional config path that was never configured; calling the static get_load_dlm wrappers indirectly with default null arguments.","solutions":["Supply a valid filename or FILE* to load_dlm.","Guard the call site with a null check on the path.","If the data is in memory, parse it yourself or convert to a file/stream first."],"exampleFix":"// before\nimg.load_dlm(path, sep); // path==nullptr\n// after\nassert(path != nullptr);\nimg.load_dlm(path, sep);","handlingStrategy":"type-guard","validationCode":"if (!path) throw std::invalid_argument(\"load_dlm requires a filename\");","typeGuard":"bool hasDlmSource(std::FILE* f, const char* name){ return f != nullptr || name != nullptr; }","tryCatchPattern":"try { img.load_dlm(path, delim); } catch (cimg_library::CImgArgumentException& e) { /* null source */ }","preventionTips":["Null-check configured paths before loader calls","Fail fast at config load time if the DLM path is unset"],"tags":["cimg","null-argument","dlm","csv"],"backgroundTag":"missing-required-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"}