Fix a few things found by valgrind. There will be more of these.

* 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
This commit is contained in:
Peter Johnson 2006-03-05 07:50:16 +00:00
parent 9a0faf7460
commit 48720ff6a6
5 changed files with 10 additions and 2 deletions

View 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;

View 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);

View 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);
}

View 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;

View 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;