fix(polygon): clear next_url between free and re-assign in pagination
This commit is contained in:
parent
4639edd813
commit
95d57d43ec
1 changed files with 7 additions and 0 deletions
|
|
@ -102,7 +102,14 @@ pub const Polygon = struct {
|
||||||
var response = try self.client.get(authed);
|
var response = try self.client.get(authed);
|
||||||
defer response.deinit();
|
defer response.deinit();
|
||||||
|
|
||||||
|
// Free the cursor URL we just consumed and clear next_url
|
||||||
|
// BEFORE attempting to parse. If parseDividendsPage errors,
|
||||||
|
// the function-scope defer at the top must not see a
|
||||||
|
// dangling pointer in next_url -- otherwise it double-frees
|
||||||
|
// the buffer we just released. The new next_url (if any)
|
||||||
|
// gets assigned below on success.
|
||||||
allocator.free(cursor_url);
|
allocator.free(cursor_url);
|
||||||
|
next_url = null;
|
||||||
next_url = try parseDividendsPage(allocator, response.body, &all_dividends);
|
next_url = try parseDividendsPage(allocator, response.body, &all_dividends);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue