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) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJhFeDkAAoJEHsCRPsS3kQiCTsH/RvpPwHd+Nkm+nnueTUbOWfJ Jra+JUzuu7bNYwrFJcQUoetbplUXqDgHnY5VBaAltrgInaZ1Xt/QtWWNBdDc2MU6 WEs5JWAZn4/3mWaglZZ8ESDx/OjCKunfYYR6fZSlXG4WgVER6O8+A+ri0h3TWoRw i/WzlvAROB3bUDvum+tqskT3zkH73NgHCcJhVAG/FiV232aDR9TJMN+OlgZ8n32Y tnfSeATTZos6ms9em1kI4ccM8KWemehnxCY+GvohMdcnxF3kvsxyWgbUfcY3JuKz 4OVnXyGZhDD5ow1ORQcqlvF1MiIst1EbKtImNifalG39lMRCTpwupWIzggo7AuA= =SZsl -----END PGP SIGNATURE----- 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>
This commit is contained in:
commit
f1a1a93646
|
@ -33,7 +33,7 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
|
||||||
{
|
{
|
||||||
uint32_t words[PACKET_WORDS_MAX];
|
uint32_t words[PACKET_WORDS_MAX];
|
||||||
bool found_end = false;
|
bool found_end = false;
|
||||||
GString *buf = g_string_sized_new(PACKET_BUFFER_LEN);
|
GString *buf;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
for (i = 0; i < PACKET_WORDS_MAX && !found_end; i++) {
|
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);
|
return PACKET_WORDS_MAX * sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf = g_string_sized_new(PACKET_BUFFER_LEN);
|
||||||
len = disassemble_hexagon(words, i, memaddr, buf);
|
len = disassemble_hexagon(words, i, memaddr, buf);
|
||||||
(*info->fprintf_func)(info->stream, "%s", buf->str);
|
(*info->fprintf_func)(info->stream, "%s", buf->str);
|
||||||
g_string_free(buf, true);
|
g_string_free(buf, true);
|
||||||
|
|
Loading…
Reference in a new issue