[PATCH 2] Fix core dump on anonymous symbol.

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

 



Using the following can generate anonymous symbol without
initializer expression.

	return (struct foo) {};

It would be nice if sparse does not crash on it.

Signed-Off-By: Christopher Li <sparse@xxxxxxxxxxx>

Index: sparse/linearize.c
===================================================================
--- sparse.orig/linearize.c	2007-01-30 19:47:10.000000000 -0800
+++ sparse/linearize.c	2007-01-30 19:47:54.000000000 -0800
@@ -116,14 +116,16 @@ const char *show_pseudo(pseudo_t pseudo)
 		}
 		expr = sym->initializer;
 		snprintf(buf, 64, "<anon symbol:%p>", sym);
-		switch (expr->type) {
-		case EXPR_VALUE:
-			snprintf(buf, 64, "<symbol value: %lld>", expr->value);
-			break;
-		case EXPR_STRING:
-			return show_string(expr->string);
-		default:
-			break;
+		if (expr) {
+			switch (expr->type) {
+			case EXPR_VALUE:
+				snprintf(buf, 64, "<symbol value: %lld>", expr->value);
+				break;
+			case EXPR_STRING:
+				return show_string(expr->string);
+			default:
+				break;
+			}
 		}
 		break;
 	}
-
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