fix segfault
This commit is contained in:
parent
71a5c548d5
commit
14df3b1050
1 changed files with 6 additions and 2 deletions
8
src/cache/store.zig
vendored
8
src/cache/store.zig
vendored
|
|
@ -274,11 +274,15 @@ pub const Store = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var reader = std.Io.Reader.fixed(data);
|
var reader = std.Io.Reader.fixed(data);
|
||||||
const parsed = srf.parse(&reader, allocator, .{ .alloc_strings = true }) catch return error.InvalidData;
|
const parsed = srf.parse(&reader, allocator, .{ .alloc_strings = false }) catch return error.InvalidData;
|
||||||
defer parsed.deinit();
|
defer parsed.deinit();
|
||||||
|
|
||||||
for (parsed.records.items) |record| {
|
for (parsed.records.items) |record| {
|
||||||
const div = record.to(Dividend) catch continue;
|
var div = record.to(Dividend) catch continue;
|
||||||
|
// Dupe owned strings before parsed.deinit() frees the backing buffer
|
||||||
|
if (div.currency) |c| {
|
||||||
|
div.currency = allocator.dupe(u8, c) catch null;
|
||||||
|
}
|
||||||
try dividends.append(allocator, div);
|
try dividends.append(allocator, div);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue