diff --git a/src/providers/polygon.zig b/src/providers/polygon.zig index 9e0eba9..5625561 100644 --- a/src/providers/polygon.zig +++ b/src/providers/polygon.zig @@ -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); }