diff options
author | Taylor Simpson | 2021-08-12 13:53:09 +0200 |
---|---|---|
committer | Taylor Simpson | 2021-08-12 16:06:05 +0200 |
commit | a7686d5d8528469b596e98eff098a5d3f8328fb3 (patch) | |
tree | a952a1f957ebdf4a84416e52a89f16a4e2bf0d5a | |
parent | Update version for v6.1.0-rc3 release (diff) | |
download | qemu-a7686d5d8528469b596e98eff098a5d3f8328fb3.tar.gz qemu-a7686d5d8528469b596e98eff098a5d3f8328fb3.tar.xz qemu-a7686d5d8528469b596e98eff098a5d3f8328fb3.zip |
Hexagon (disas/hexagon.c) fix memory leak for early exit cases
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>
-rw-r--r-- | disas/hexagon.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/disas/hexagon.c b/disas/hexagon.c index 3c24e2a94a..c1a4ffc5f6 100644 --- a/disas/hexagon.c +++ b/disas/hexagon.c @@ -33,7 +33,7 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info) { 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++) { @@ -57,6 +57,7 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info) 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); |