1 Commits

Author SHA1 Message Date
Dreladwyn 201145bdd9 fix crash reading past end of memory-mapped model file (#7021)
* fix crash reading past end of memory-mapped model file

DataReaderFromMemory used by mapped model loading was unbounded:
read()/reference() advanced past the mapped region, so a truncated
or corrupt .bin crashed with an access violation inside
ModelBinFromDataReader instead of failing cleanly.

Add a size-aware DataReaderFromMemory ctor that clamps reads and
fails references past the end, use it in the mapped branches of
Net::load_model, and propagate load_model()'s return value which
was previously dropped.

* fix bounded memory reader scans and add loading regressions

* f

* reuse bounded memory reader scan buffer

---------

Co-authored-by: Dr3ladwyn <Dr3ladwyn@users.noreply.github.com>
Co-authored-by: nihui <nihuini@tencent.com>
2026-10-12 00:01:46 +08:00