Fix core dump on anonymous symbol.
Christopher Li
maintainerPATCH 1/1 Fix core dump on anonymous symbol.
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 <[email protected]>
linearize.c +10 -8
@@ -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 ; }
Quoted 8 lines · Christopher Li
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 <[email protected]>
I tried several variants of the code you suggest, but I couldn't seem to reproduce the problem this solves. Could you supply a full .c file for a test case?
In any case, applied.
- Josh Triplett