staticlibs / ccronexpr

Cron expression parsing in ANSI C
Apache License 2.0
150 stars 78 forks source link

Memory leak in `to_string`? #13

Closed alfred-ai closed 6 years ago

alfred-ai commented 6 years ago

CppCheck reported a memory leak here: https://github.com/staticlibs/ccronexpr/blob/7687339ce8b8d9bb7c11fbb809cf6b64da827a72/ccronexpr.c#L501

This is really a leak according to my understand of the code, where the memory is gone in case sprintf failed.

staticlibs commented 6 years ago

Agree, looks like a real leak, cron_free should be added into the res < 0 check. I can merge a PR for that or can add this change myself (will take a couple of days).