[Issue 3724] New: bug in Expression::arraySyntaxCopy (null pointer dereference on struct->union->struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 19 19:14:36 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3724
Summary: bug in Expression::arraySyntaxCopy (null pointer
dereference on struct->union->struct
Product: D
Version: 2.039
Platform: x86
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: baryluk at smp.if.uj.edu.pl
--- Comment #0 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2010-01-19 19:14:35 PST ---
In case of code similar to this
struct v {
union {
struct { float a, b; }
struct { float c[2]; }
}
}
(it is more complicated than just this sample, to trigger this bug.
I can't easly produce small example)
file expression.c
method Expression *StructLiteralExp::semantic(Scope *sc)
performs kind of flatening, and adds member c to array "elements",
but in case on union memberrs it adds them as null:
relevant lines:
line 3373
if (v->offset < offset)
{ e = NULL;
sd->hasUnions = 1;
}
and line 3393
elements->push(e)
Fix:
In file expression.c line 1477
method Expressions *Expression::arraySyntaxCopy(Expressions *exps)
add condition:
for (int i = 0; i < a->dim; i++)
{ Expression *e = (Expression *)exps->data[i];
- e = e->syntaxCopy();
+ if (e)
+ e = e->syntaxCopy();
a->data[i] = e;^M
}
Without it, optimize.c lines 86-87 will call indirectly this method, when some
(last) elemenets of exps is/are nulls, and segfault.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list