Hexagon (disas/hexagon.c) fix memory leak for early exit cases
PATCH 1/1 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)
Signed-off-by Taylor Simpson <[email protected]>
--- disas/hexagon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
disas/hexagon.c +2 -1
@@ -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);
Signature · 1 line
2.7.4
Quoted 25 lines · Taylor Simpson
Don't allocate the string until error conditions have been checked
Fixes a00cfed0e ("Hexagon (disas) disassembler")Eliminate Coverity CID 1460121 (Resource leak)
Signed-off-by Taylor Simpson <[email protected]>--- disas/hexagon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)disas/hexagon.c +1
-1@@ -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++) {
disas/hexagon.c int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
Quoted 8 lines
disas/hexagon.c +1
-1@@ -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); --
Reviewed-by Peter Maydell <[email protected]>
thanks
-- PMM
Quoted 9 lines · Taylor Simpson
Don't allocate the string until error conditions have been checked
Fixes a00cfed0e ("Hexagon (disas) disassembler")Eliminate Coverity CID 1460121 (Resource leak)
Signed-off-by Taylor Simpson <[email protected]>--- disas/hexagon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by Philippe Mathieu-Daudé <[email protected]>