summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2021-08-15 12:14:23 +0200
committerPeter Maydell2021-08-15 12:14:23 +0200
commitf1a1a93646f49d710bc3937dd72e7a53b4a2fc6a (patch)
tree9eb6360dc88287fc4878aa37296ec96918632210
parentMerge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into ... (diff)
parentHexagon (disas/hexagon.c) fix memory leak for early exit cases (diff)
downloadqemu-f1a1a93646f49d710bc3937dd72e7a53b4a2fc6a.tar.gz
qemu-f1a1a93646f49d710bc3937dd72e7a53b4a2fc6a.tar.xz
qemu-f1a1a93646f49d710bc3937dd72e7a53b4a2fc6a.zip
Merge remote-tracking branch 'remotes/quic/tags/pull-hex-20210812' into staging
Hexagon (disas/hexagon.c) fix memory leak for early exit Don't allocate the string until error conditions have been checked Fixes: a00cfed0e ("Hexagon (disas) disassembler") Eliminate Coverity CID 1460121 (Resource leak) # gpg: Signature made Fri 13 Aug 2021 04:03:00 BST # gpg: using RSA key 7B0244FB12DE4422 # gpg: Good signature from "Taylor Simpson (Rock on) <tsimpson@quicinc.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 3635 C788 CE62 B91F D4C5 9AB4 7B02 44FB 12DE 4422 * remotes/quic/tags/pull-hex-20210812: Hexagon (disas/hexagon.c) fix memory leak for early exit cases Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--disas/hexagon.c3
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);