Check sqlite3_malloc64 result in Deserialize

This commit is contained in:
Yasuhiro Matsumoto
2026-07-13 10:17:21 +09:00
parent 78710fc089
commit 7d6ccee48e

View File

@@ -60,6 +60,9 @@ func (c *SQLiteConn) Deserialize(b []byte, schema string) error {
defer C.free(unsafe.Pointer(zSchema)) defer C.free(unsafe.Pointer(zSchema))
tmpBuf := (*C.uchar)(C.sqlite3_malloc64(C.sqlite3_uint64(len(b)))) tmpBuf := (*C.uchar)(C.sqlite3_malloc64(C.sqlite3_uint64(len(b))))
if tmpBuf == nil && len(b) > 0 {
return fmt.Errorf("deserialize failed: out of memory")
}
copy(unsafe.Slice((*byte)(unsafe.Pointer(tmpBuf)), len(b)), b) copy(unsafe.Slice((*byte)(unsafe.Pointer(tmpBuf)), len(b)), b)
rc := C.sqlite3_deserialize(c.db, zSchema, tmpBuf, C.sqlite3_int64(len(b)), rc := C.sqlite3_deserialize(c.db, zSchema, tmpBuf, C.sqlite3_int64(len(b)),