Skip to contentSkip to conversation

Fix potential NULL pointer deref in gen_init_cpio

PATCH New Jesper Juhl 1 participant 1 message Mar 18, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix potential NULL pointer deref in gen_init_cpio

Fix potential NULL pointer deref in gen_init_cpio.c spotted by coverity checker.
This fixes coverity bug #86

---

 usr/gen_init_cpio.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)
usr/gen_init_cpio.c +3 -1
@@ -471,6 +471,7 @@ int main (int argc, char *argv[])
 				"ERROR: incorrect format, could not locate file type line %d: '%s'\n",
 				line_nr, line);
 			ec = -1;
+			break;
 		}
 
 		if ('\n' == *type) {
@@ -506,7 +507,8 @@ int main (int argc, char *argv[])
 				line_nr, line);
 		}
 	}
-	cpio_trailer();
+	if (ec == 0)
+		cpio_trailer();
 
 	exit(ec);
 }