fix(polygon): clear next_url between free and re-assign in pagination

This commit is contained in:
Emil Lerch 2026-06-01 12:14:55 -07:00
parent 4639edd813
commit 95d57d43ec
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -102,7 +102,14 @@ pub const Polygon = struct {
var response = try self.client.get(authed);
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);
next_url = null;
next_url = try parseDividendsPage(allocator, response.body, &all_dividends);
}