mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-13 11:29:30 +00:00
Fix crash or error in certain cases when using common subexpression elimination.
In certain rare cases, constant subexpression elimination could set the left subtree of a pc_bno operation in the intermediate code to nil. This could lead to null pointer dereferences, sometimes resulting in a crash or error during native code generation. The below program sometimes demonstrates the problem (dependent on zero page contents): #pragma optimize 16 struct F {int *p;}; void foo(struct F* f) { struct {int c;} s = {0}; ++f->p; s.c |= *--f->p; }
This commit is contained in:
parent
8b339a9ab7
commit
a09581b84e
5
DAG.pas
5
DAG.pas
|
@ -2531,6 +2531,11 @@ var
|
||||||
end {if}
|
end {if}
|
||||||
else
|
else
|
||||||
op2 := op3^.left;
|
op2 := op3^.left;
|
||||||
|
if op2 = nil then begin
|
||||||
|
op2 := pointer(Calloc(sizeof(intermediate_code)));
|
||||||
|
op2^.opcode := pc_nop;
|
||||||
|
op2^.optype := cgWord;
|
||||||
|
end; {if}
|
||||||
op1^.left := op3; {place in the new location}
|
op1^.left := op3; {place in the new location}
|
||||||
end; {Combine}
|
end; {Combine}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user