Added checks for NULL pointer dereference
git-svn-id: http://picoc.googlecode.com/svn/trunk@258 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
f6d397211d
commit
8c918707f2
|
@ -223,6 +223,9 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
||||||
if (TopValue->Typ->Base != TypePointer)
|
if (TopValue->Typ->Base != TypePointer)
|
||||||
ProgramFail(Parser, "can't dereference this non-pointer");
|
ProgramFail(Parser, "can't dereference this non-pointer");
|
||||||
|
|
||||||
|
if (TopValue->Val->Pointer.Segment == NULL)
|
||||||
|
ProgramFail(Parser, "can't dereference NULL pointer");
|
||||||
|
|
||||||
// XXX - should also do offset + checks
|
// XXX - should also do offset + checks
|
||||||
ExpressionStackPushLValue(Parser, StackTop, TopValue->Val->Pointer.Segment);
|
ExpressionStackPushLValue(Parser, StackTop, TopValue->Val->Pointer.Segment);
|
||||||
break;
|
break;
|
||||||
|
@ -619,6 +622,8 @@ void ExpressionGetStructElement(struct ParseState *Parser, struct ExpressionStac
|
||||||
|
|
||||||
// XXX - should also do offset + checks
|
// XXX - should also do offset + checks
|
||||||
StructVal = ParamVal->Val->Pointer.Segment;
|
StructVal = ParamVal->Val->Pointer.Segment;
|
||||||
|
if (StructVal == NULL)
|
||||||
|
ProgramFail(Parser, "can't dereference NULL pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StructVal->Typ->Base != TypeStruct && StructVal->Typ->Base != TypeUnion)
|
if (StructVal->Typ->Base != TypeStruct && StructVal->Typ->Base != TypeUnion)
|
||||||
|
|
Loading…
Reference in a new issue