{"record":{"id":"c746779e9f402f85","repo":"Yalantis/uCrop","slug":"cimglist-s-get-unserialize-specified-seriali","errorCode":null,"errorMessage":"CImgList<%s>::get_unserialize(): Specified serialized buffer is (null).","messagePattern":"CImgList<(.+?)>::get_unserialize\\(\\): Specified serialized buffer is \\(null\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":68846,"sourceCode":"          if (W*H*D*C>0) { \\\n            CImg<Tss> raw; \\\n            CImg<T> &img = res._data[l]; \\\n            if (err==5) _cimgz_unserialize_case(Tss) \\\n            else { \\\n              raw.assign(W,H,D,C); \\\n              CImg<ucharT> _raw((unsigned char*)raw._data,W*sizeof(Tss),H,D,C,true); \\\n              if (sizeof(t)==1) { std::memcpy(_raw,stream,_raw.size()); stream+=_raw.size(); } \\\n              else cimg_for(_raw,p,unsigned char) *p = (unsigned char)*(stream++); \\\n            } \\\n            if (endian!=cimg::endianness()) cimg::invert_endianness(raw._data,raw.size()); \\\n            raw.move_to(img); \\\n          } \\\n        } \\\n        loaded = true; \\\n      }\n\n      if (buffer.is_empty())\n        throw CImgArgumentException(\"CImgList<%s>::get_unserialize(): Specified serialized buffer is (null).\",\n                                    pixel_type());\n      CImgList<T> res;\n      const t *stream = buffer._data + header_size, *const estream = buffer._data + buffer.size();\n      bool loaded = false, endian = cimg::endianness(), is_bytef = false;\n      CImg<charT> tmp(256), str_pixeltype(256), str_endian(256);\n      *tmp = *str_pixeltype = *str_endian = 0;\n      unsigned int j, N = 0, W, H, D, C;\n      uint64T csiz;\n      int i, err;\n      cimg::unused(is_bytef);\n      do {\n        j = 0; while ((i=(int)*stream)!='\\n' && stream<estream && j<255) { ++stream; tmp[j++] = (char)i; }\n        ++stream; tmp[j] = 0;\n      } while (*tmp=='#' && stream<estream);\n      err = cimg_sscanf(tmp,\"%u%*c%255[A-Za-z123468_]%*c%255[sA-Za-z_ ]\",\n                        &N,str_pixeltype._data,str_endian._data);\n      if (err<2)\n        throw CImgArgumentException(\"CImgList<%s>::get_unserialize(): CImg header not found in serialized buffer.\",","sourceCodeStart":68828,"sourceCodeEnd":68864,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L68828-L68864","documentation":"CImgList::get_unserialize() was called with an empty buffer (CImg buffer is_empty()), so there is no data to deserialize at all. CImg rejects this up front with CImgArgumentException rather than attempting to parse a null stream.","triggerScenarios":"Calling unserialize()/get_unserialize() with a default-constructed CImg<t> buffer, a failed load that produced an empty buffer, or a zero-length file read passed straight into unserialize.","commonSituations":"Reading an input file that came back empty (missing resource in APK/assets, failed download saved as 0 bytes); forgetting to check the result of a previous load before re-serializing.","solutions":["Check buffer.is_empty() (or file size > 0) before calling unserialize.","Fix the upstream load/read that produced the empty buffer — verify the source file exists and is non-empty.","On Android, confirm the asset/resource was actually bundled and opened successfully before deserializing."],"exampleFix":"// before\nCImgList<unsigned char> imgs;\nimgs.unserialize(raw); // throws if raw is empty\n// after\nif (raw.is_empty()) throw std::runtime_error(\"serialized buffer is empty\");\nCImgList<unsigned char> imgs;\nimgs.unserialize(raw);","handlingStrategy":"validation","validationCode":"if (raw.is_empty()) {\n  throw std::runtime_error(\"cannot unserialize: buffer is empty\");\n}","typeGuard":"template <typename t>\nbool nonEmptyBuffer(const CImg<t>& b) { return !b.is_empty(); }","tryCatchPattern":"try {\n  imgs.unserialize(raw);\n} catch (CImgArgumentException& e) {\n  cimg::warn(\"empty buffer passed to unserialize: %s\", e.what());\n}","preventionTips":["Always check is_empty() on buffers loaded from files or network before deserializing.","Check file size > 0 after reading input.","Verify asset/download succeeded before parsing."],"tags":["serialization","empty-buffer","null-argument","native"],"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"}