{"record":{"id":"f06f6a787fe4a872","repo":"Yalantis/uCrop","slug":"load-yuv-specified-filename-is-null","errorCode":null,"errorMessage":"load_yuv(): Specified filename is (null).","messagePattern":"load_yuv\\(\\): Specified filename is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67192,"sourceCode":"    }\n\n    //! Load a list from an image sequence YUV file \\newinstance.\n    static CImgList<T> get_load_yuv(std::FILE *const file,\n                                    const unsigned int size_x, const unsigned int size_y=1,\n                                    const unsigned int chroma_subsampling=444,\n                                    const unsigned int first_frame=0, const unsigned int last_frame=~0U,\n                                    const unsigned int step_frame=1, const bool yuv2rgb=true) {\n      return CImgList<T>().load_yuv(file,size_x,size_y,chroma_subsampling,\n                                    first_frame,last_frame,step_frame,yuv2rgb);\n    }\n\n    CImgList<T>& _load_yuv(std::FILE *const file, const char *const filename,\n                           const unsigned int size_x, const unsigned int size_y,\n                           const unsigned int chroma_subsampling,\n                           const unsigned int first_frame, const unsigned int last_frame,\n                           const unsigned int step_frame, const bool yuv2rgb) {\n      if (!filename && !file)\n        throw CImgArgumentException(_cimglist_instance\n                                    \"load_yuv(): Specified filename is (null).\",\n                                    cimglist_instance);\n      if (chroma_subsampling!=420 && chroma_subsampling!=422 && chroma_subsampling!=444)\n        throw CImgArgumentException(_cimglist_instance\n                                    \"load_yuv(): Specified chroma subsampling %u is invalid, for file '%s'.\",\n                                    cimglist_instance,\n                                    chroma_subsampling,filename?filename:\"(FILE*)\");\n      const unsigned int\n        cfx = chroma_subsampling==420 || chroma_subsampling==422?2:1,\n        cfy = chroma_subsampling==420?2:1,\n        nfirst_frame = first_frame<last_frame?first_frame:last_frame,\n        nlast_frame = first_frame<last_frame?last_frame:first_frame,\n        nstep_frame = step_frame?step_frame:1;\n\n      if (!size_x || !size_y || size_x%cfx || size_y%cfy)\n        throw CImgArgumentException(_cimglist_instance\n                                    \"load_yuv(): Specified dimensions (%u,%u) are invalid, for file '%s'.\",\n                                    cimglist_instance,","sourceCodeStart":67174,"sourceCodeEnd":67210,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67174-L67210","documentation":"CImgList::_load_yuv() can read raw YUV video either from a FILE* or from a filename, but at least one must be provided. When both are null CImg throws CImgArgumentException because there is no data source.","triggerScenarios":"Calling load_yuv(nullptr, ...) / _load_yuv(nullptr, nullptr, ...) with both the file pointer and filename null; passing a null char* filename and no open FILE*.","commonSituations":"Unset config value or failed lookup yielding a null path; calling the public load_yuv(filename,...) overload with a null string; refactored code that stopped opening the file before calling the internal loader.","solutions":["Pass a valid filename string, or open the file yourself and pass the FILE*","Validate the path (non-null, non-empty) before calling","Fix the upstream source of the null path (env var, config, argv)"],"exampleFix":"// before\nimgs.load_yuv(NULL, 640, 480); // no filename, no FILE*\n// after\nstd::FILE* f = std::fopen(\"video.yuv\", \"rb\");\nimgs.load_yuv(f, 640, 480); // or: imgs.load_yuv(\"video.yuv\", 640, 480);","handlingStrategy":"type-guard","validationCode":"if (!filename && !file) { /* raise app-level 'no YUV source' error */ }","typeGuard":"bool hasYuvSource(const char* filename, std::FILE* file) { return filename != nullptr || file != nullptr; }","tryCatchPattern":"try { imgs.load_yuv(filename, w, h, 420); }\ncatch (CImgArgumentException& e) { fprintf(stderr, \"no YUV source given: %s\\n\", e.what()); }","preventionTips":["Resolve and validate the source path before calling loaders","Never rely on default-initialized char* pointers","Centralize file-opening so null sources fail with a clear app message"],"tags":["cimg","yuv","null-argument","video-loading"],"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"}