Fixed a memory leak for payload parse errors

### Description
The pointer to the result of the parse was copied as output after the function returns a 'parse error'.
So, in case of parse error, the caller cannot cleanup the allocated data during the parse.
The fix is more than simple - just copy the pointer before 'return parse-error'