]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix memory leaks in the sysinfo program.
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 6 Jun 2017 13:52:31 +0000 (14:52 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 6 Jun 2017 13:52:31 +0000 (14:52 +0100)
* sysinfo.y: Free memory allocated by token NAME.

binutils/ChangeLog
binutils/sysinfo.y

index 1ecb04297b90eeb5577bdd0c4aa7221e8d79c801..0766e670709477ccd2d39d690dcb05707ae0892e 100644 (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>
 
        * doc/binutils.texi: Document new cpu=... disassembler options for ARC.
index 62758de93711198ad2f5108a1a409c887e2dcec6..1c8f1ff221a6bfd65f3f7f190b8bcf88fe8bc73d 100644 (file)
@@ -21,6 +21,7 @@
 %{
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 static char writecode;
 static char *it;
@@ -159,6 +160,8 @@ it:
   case 'c':
     printf("}\n");
   }
+
+  free (it);
 }
 ;
 
@@ -204,6 +207,8 @@ repeat_it_field: '(' REPEAT NAME
         it_field_list ')'
 
        {
+         free (repeat);
+
          repeat = oldrepeat;
          oldrepeat =0;
          rdepth--;
@@ -230,6 +235,8 @@ cond_it_field: '(' COND NAME
              printf("\tif (%s) {\n", $3);
              break;
            }
+
+         free ($3);
        }
 
         it_field_list ')'
@@ -348,6 +355,9 @@ char *ptr = pnames[rdepth];
              else abort();
                  break;
                }
+
+         free (desc);
+         free (id);
        }
 
        ;
@@ -371,7 +381,7 @@ attr_size:
 
 attr_id:
                '(' NAME ')'    { $$ = $2; }
-       |       { $$ = "dummy";}
+       |       { $$ = strdup ("dummy");}
        ;
 
 enums:
@@ -388,6 +398,9 @@ enum_list:
            case 'c':
                printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],$4,$3);
            }
+
+         free ($3);
+         free ($4);
        }
 
        ;