ludic.save, ludic.telemetry: a parsed tree they refuse is freed (23.2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 22:51:06 +03:00
parent f1153f59a2
commit e227b75472
2 changed files with 9 additions and 3 deletions

View file

@ -6,8 +6,10 @@ export function save_parse(text: string, f: SaveFormat) -> SaveRead {
if text == null { return read_new(SAVE_NONE, null) }
if not save_text_intact(text) { return read_new(SAVE_CORRUPT, null) }
let v = Json.parse(text)
if value_kind(v) != 6 { return read_new(SAVE_CORRUPT, null) } # 6 is an object
if f.is_one != null and not f.is_one(v) { return read_new(SAVE_CORRUPT, null) }
if value_kind(v) != 6 or (f.is_one != null and not f.is_one(v)) { # 6 is an object
if v != null { Json.free(v) } # a refused tree is let go
return read_new(SAVE_CORRUPT, null)
}
return read_new(SAVE_OK, v)
}

View file

@ -92,6 +92,10 @@ function telemetry__read_obj(path: string) -> Val {
let s = Fs.read_text(path)
if s == null { return null }
let v = Json.parse(s)
if v == null or Value.kind(v) != 6 { return null }
if v == null { return null }
if Value.kind(v) != 6 {
Json.free(v)
return null
}
return v
}