From 95d57d43ec0646a8691536b79652c6577e8131ff Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Mon, 1 Jun 2026 12:14:55 -0700 Subject: [PATCH] fix(polygon): clear next_url between free and re-assign in pagination --- src/providers/polygon.zig | 7 +++++++ 1 file changed, 7 insertions(+) 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); }