Don't allocate the string until error conditions have been checked
Fixes: a00cfed0e ("Hexagon (disas) disassembler")
Eliminate Coverity CID
1460121 (Resource leak)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daud? <f4bug@amsat.org>
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
{
uint32_t words[PACKET_WORDS_MAX];
bool found_end = false;
- GString *buf = g_string_sized_new(PACKET_BUFFER_LEN);
+ GString *buf;
int i, len;
for (i = 0; i < PACKET_WORDS_MAX && !found_end; i++) {
return PACKET_WORDS_MAX * sizeof(uint32_t);
}
+ buf = g_string_sized_new(PACKET_BUFFER_LEN);
len = disassemble_hexagon(words, i, memaddr, buf);
(*info->fprintf_func)(info->stream, "%s", buf->str);
g_string_free(buf, true);