OSDN Git Service

Usischev Yury pointed out a use after free error.
authorRob Landley <rob@landley.net>
Sat, 23 Jul 2016 23:12:48 +0000 (18:12 -0500)
committerRob Landley <rob@landley.net>
Sat, 23 Jul 2016 23:12:48 +0000 (18:12 -0500)
toys/posix/sed.c

index 45816c2..45331ba 100644 (file)
@@ -635,8 +635,6 @@ writenow:
   if (line && !(toys.optflags & FLAG_n)) emit(line, len, eol);
 
 done:
-  free(line);
-
   if (dlist_terminate(append)) while (append) {
     struct append *a = append->next;
 
@@ -655,6 +653,7 @@ done:
     free(append);
     append = a;
   }
+  free(line);
 }
 
 // Genericish function, can probably get moved to lib.c