mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-02-08 02:30:59 +00:00
Fix two places in the optimizer where null pointers could be dereferenced.
These were generally fairly harmless, but one could have caused problems if the zero page contained certain values.
This commit is contained in:
parent
a09581b84e
commit
2190b7e7ed
16
DAG.pas
16
DAG.pas
@ -154,7 +154,7 @@ else if (op1 <> nil) and (op2 <> nil) then
|
|||||||
if op1^.q = op2^.q then
|
if op1^.q = op2^.q then
|
||||||
if op1^.r = op2^.r then
|
if op1^.r = op2^.r then
|
||||||
if op1^.s = op2^.s then
|
if op1^.s = op2^.s then
|
||||||
if op1^.lab^ = op2^.lab^ then
|
if (op1^.lab = op2^.lab) or (op1^.lab^ = op2^.lab^) then
|
||||||
if OpsEqual(op1, op2) then
|
if OpsEqual(op1, op2) then
|
||||||
if op1^.optype = op2^.optype then
|
if op1^.optype = op2^.optype then
|
||||||
case op1^.optype of
|
case op1^.optype of
|
||||||
@ -768,23 +768,28 @@ case op^.opcode of {check for optimizations of this node}
|
|||||||
opv := op^.left;
|
opv := op^.left;
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
|
done := false;
|
||||||
if op^.left^.opcode = pc_ldc then
|
if op^.left^.opcode = pc_ldc then
|
||||||
ReverseChildren(op);
|
ReverseChildren(op);
|
||||||
if op^.right^.opcode = pc_ldc then begin
|
if op^.right^.opcode = pc_ldc then begin
|
||||||
lval := op^.right^.lval;
|
lval := op^.right^.lval;
|
||||||
if lval = 0 then
|
if lval = 0 then begin
|
||||||
opv := op^.left
|
opv := op^.left;
|
||||||
|
done := true;
|
||||||
|
end {if}
|
||||||
else if (lval >= 0) and (lval <= maxint) then begin
|
else if (lval >= 0) and (lval <= maxint) then begin
|
||||||
op^.opcode := pc_inc;
|
op^.opcode := pc_inc;
|
||||||
op^.optype := cgLong;
|
op^.optype := cgLong;
|
||||||
op^.q := ord(lval);
|
op^.q := ord(lval);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
|
done := true;
|
||||||
end {else if}
|
end {else if}
|
||||||
else if (lval > -maxint) and (lval < 0) then begin
|
else if (lval > -maxint) and (lval < 0) then begin
|
||||||
op^.opcode := pc_dec;
|
op^.opcode := pc_dec;
|
||||||
op^.optype := cgLong;
|
op^.optype := cgLong;
|
||||||
op^.q := -ord(lval);
|
op^.q := -ord(lval);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
|
done := true;
|
||||||
end; {else if}
|
end; {else if}
|
||||||
end {if}
|
end {if}
|
||||||
else if CodesMatch(op^.left, op^.right, false) then
|
else if CodesMatch(op^.left, op^.right, false) then
|
||||||
@ -796,10 +801,11 @@ case op^.opcode of {check for optimizations of this node}
|
|||||||
optype := cgLong;
|
optype := cgLong;
|
||||||
end; {with}
|
end; {with}
|
||||||
op^.opcode := pc_sll;
|
op^.opcode := pc_sll;
|
||||||
|
done := true;
|
||||||
end; {if}
|
end; {if}
|
||||||
if op^.right^.opcode in [pc_lao,pc_lda,pc_ixa] then
|
if not done and (op^.right^.opcode in [pc_lao,pc_lda,pc_ixa]) then
|
||||||
ReverseChildren(op);
|
ReverseChildren(op);
|
||||||
if op^.left^.opcode in [pc_lao,pc_lda,pc_ixa] then
|
if not done and (op^.left^.opcode in [pc_lao,pc_lda,pc_ixa]) then
|
||||||
if op^.right^.opcode = pc_sll then begin
|
if op^.right^.opcode = pc_sll then begin
|
||||||
if op^.right^.right^.opcode = pc_ldc then
|
if op^.right^.right^.opcode = pc_ldc then
|
||||||
if (op^.right^.right^.lval & $FFFF8000) = 0 then
|
if (op^.right^.right^.lval & $FFFF8000) = 0 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user