Fix memory leaks in the sysinfo program.

* sysinfo.y: Free memory allocated by token NAME.
This commit is contained in:
Simon Marchi
2017-06-06 14:52:31 +01:00
committed by Nick Clifton
parent 0ee3a6dbd0
commit d24b756188
2 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2017-06-06 Simon Marchi <simon.marchi@ericsson.com>
* sysinfo.y: Free memory allocated by token NAME.
2017-05-30 Anton Kolesov <anton.kolesov@synopsys.com> 2017-05-30 Anton Kolesov <anton.kolesov@synopsys.com>
* doc/binutils.texi: Document new cpu=... disassembler options for ARC. * doc/binutils.texi: Document new cpu=... disassembler options for ARC.

View File

@ -21,6 +21,7 @@
%{ %{
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
static char writecode; static char writecode;
static char *it; static char *it;
@ -159,6 +160,8 @@ it:
case 'c': case 'c':
printf("}\n"); printf("}\n");
} }
free (it);
} }
; ;
@ -204,6 +207,8 @@ repeat_it_field: '(' REPEAT NAME
it_field_list ')' it_field_list ')'
{ {
free (repeat);
repeat = oldrepeat; repeat = oldrepeat;
oldrepeat =0; oldrepeat =0;
rdepth--; rdepth--;
@ -230,6 +235,8 @@ cond_it_field: '(' COND NAME
printf("\tif (%s) {\n", $3); printf("\tif (%s) {\n", $3);
break; break;
} }
free ($3);
} }
it_field_list ')' it_field_list ')'
@ -348,6 +355,9 @@ char *ptr = pnames[rdepth];
else abort(); else abort();
break; break;
} }
free (desc);
free (id);
} }
; ;
@ -371,7 +381,7 @@ attr_size:
attr_id: attr_id:
'(' NAME ')' { $$ = $2; } '(' NAME ')' { $$ = $2; }
| { $$ = "dummy";} | { $$ = strdup ("dummy");}
; ;
enums: enums:
@ -388,6 +398,9 @@ enum_list:
case 'c': case 'c':
printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],$4,$3); printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],$4,$3);
} }
free ($3);
free ($4);
} }
; ;