]> granicus.if.org Git - yasm/commitdiff
Fix a few things found by valgrind. There will be more of these.
authorPeter Johnson <peter@tortall.net>
Sun, 5 Mar 2006 07:50:16 +0000 (07:50 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 5 Mar 2006 07:50:16 +0000 (07:50 -0000)
* bytecode.c (yasm_bc_create_insn): Initialize operands list if none were
given.
* section.c (yasm_object_destroy): Free filenames.
* gas-token.c (fill): Use memmove instead of memcpy on overlapping memory
copy.
* nasm-token.c (fill): Likewise.
* elf.c (elf_secthead_destroy): Free size member.

svn path=/trunk/yasm/; revision=1399

libyasm/bytecode.c
libyasm/section.c
modules/objfmts/elf/elf.c
modules/parsers/gas/gas-token.re
modules/parsers/nasm/nasm-token.re

index d3d039a22a0835228ba20da16f87504154793f0e..6718431c17281d4e11b622b33228cb87428ba9fa 100644 (file)
@@ -1156,6 +1156,8 @@ yasm_bc_create_insn(yasm_arch *arch, const unsigned long insn_data[4],
     insn->num_operands = num_operands;
     if (operands)
        insn->operands = *operands;     /* structure copy */
+    else
+       STAILQ_INIT(&insn->operands);
     insn->num_prefixes = 0;
     insn->prefixes = NULL;
     insn->num_segregs = 0;
index 54d49b5f0ad17827580f1d42447a90913126607f..12b63bd959655496fe3d75560e33e52d266e41c0 100644 (file)
@@ -309,6 +309,10 @@ yasm_object_destroy(yasm_object *object)
        cur = next;
     }
 
+    /* Delete associated filenames */
+    yasm_xfree(object->src_filename);
+    yasm_xfree(object->obj_filename);
+
     /* Delete symbol table and line mappings */
     yasm_symtab_destroy(object->symtab);
     yasm_linemap_destroy(object->linemap);
index 84d50739294b960971184702ecd11e1d517b1b2e..0734dff570827397f1718dad35db5024bab4dc23 100644 (file)
@@ -567,6 +567,8 @@ elf_secthead_destroy(elf_secthead *shead)
     if (shead == NULL)
        yasm_internal_error(N_("shead is null"));
 
+    yasm_intnum_destroy(shead->size);
+
     yasm_xfree(shead);
 }
 
index 247c8980904c0a863e8f065c38fdb03549d26a2a..aa923634027a7584820c78aa8f215a44d0ac3161 100644 (file)
@@ -137,7 +137,7 @@ fill(yasm_parser_gas *parser_gas, YYCTYPE *cursor)
     if(!s->eof){
        size_t cnt = s->tok - s->bot;
        if(cnt){
-           memcpy(s->bot, s->tok, (size_t)(s->lim - s->tok));
+           memmove(s->bot, s->tok, (size_t)(s->lim - s->tok));
            s->tok = s->bot;
            s->ptr -= cnt;
            cursor -= cnt;
index 6d9f00647667a0223fcdcae9b07fd90dc36a010d..e06ec2c8a57873abd67d5cefa30a00559350202a 100644 (file)
@@ -62,7 +62,7 @@ fill(yasm_parser_nasm *parser_nasm, YYCTYPE *cursor)
     if(!s->eof){
        size_t cnt = s->tok - s->bot;
        if(cnt){
-           memcpy(s->bot, s->tok, (size_t)(s->lim - s->tok));
+           memmove(s->bot, s->tok, (size_t)(s->lim - s->tok));
            s->tok = s->bot;
            s->ptr -= cnt;
            cursor -= cnt;