[PATCH 2/2] sparse, llvm: don't compile erroneous code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If sparse emits an error message while parsing a file, don't
generate LLVM code, and also don't parse further files. This
prevents a segfault when sparse-llvm is fed with certain junk.

Cc: Pekka Enberg <penberg@xxxxxxxxxx>
Cc: Christopher Li <sparse@xxxxxxxxxxx>
Cc: Jeff Garzik <jgarzik@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>
---
 sparse-llvm.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index e4929e9..0fc0dae 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -1268,7 +1268,10 @@ int main(int argc, char **argv)
 	compile(module, sparse_initialize(argc, argv, &filelist));
 
 	FOR_EACH_PTR_NOTAG(filelist, file) {
-		compile(module, sparse(file));
+		struct symbol_list *symlist = sparse(file);
+		if (error_happened)
+			break;
+		compile(module, symlist);
 	} END_FOR_EACH_PTR_NOTAG(file);
 
 	LLVMVerifyModule(module, LLVMPrintMessageAction, NULL);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux