decode: prometheus: fix to avoid freeing non-malloced data
The fuzzer in https://github.com/fluent/fluent-bit/pull/7745 found a bug that shows the prometheus decoder is sometimes freeing data that is not malloced. This is an attempt to fix that.
Please do verify this -- the fuzzer no longer finds the issue here and the bug is obvious, however, for coming up with a fix I found the code a bit tricky to validate as I'm not deeply familiar with this decoder.
ping @DavidKorczynski on changes requested
I think the issue highlighted by this PR may need a more substantial fix. There is mixing of dynamically allocated memory and non-dynamically allocated memory, and in order to achieve consistency there is some rewriting needed (not just fixing). I think the owner/maintainer of the code should address the issues -- @tarruda can you assist here?
@tarruda it seems this needs a more elaborated solution. would you please take a look at it ? (cc: @niedbalski for visibility)