| From: | Shixin Wang <wang-shi-xin(at)outlook(dot)com> |
|---|---|
| To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Fix memory leak in tzparser.c |
| Date: | 2025-12-16 05:55:32 |
| Message-ID: | 13537FFC-5C55-470E-A75B-18F32186F301@outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers,
I noticed a memory leak in the addToArray() function in src/backend/utils/misc/tzparser.c.
When the override parameter is true and a duplicate timezone abbreviation is found,
the code overwrites midptr->zone without freeing the previously allocated memory.
The fix would be:
- midptr->zone = entry->zone;
+ if (midptr->zone != NULL)
+ pfree(midptr->zone);
+ midptr->zone = entry->zone;
While the memory is managed by a temp memory context that gets cleaned up
eventually, the coarse-grained management might cause some memory to
accumulate during ParseTzFile() recursive calls when processing @INCLUDE
directives.
I've attached a patch with this change in case anyone thinks it's worth
applying.
Regards,
Shixin Wang
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-memory-leak-in-tzparser.patch | application/octet-stream | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Murtuza Zabuawala | 2025-12-16 05:56:30 | Re: [PATCH] Add zstd compression for TOAST using extended header format |
| Previous Message | Chao Li | 2025-12-16 05:48:37 | Re: Implement waiting for wal lsn replay: reloaded |