Oberon.Call Can Leave 'res' Undefined
Posted: Wed Jun 02, 2021 4:39 am
This applies to Embedded Oberon.
Oberon.Call:
Oberon.Call has a code path that leaves 'res' in an undefined state, namely if no dot "." is found in the command string, which can result in erroneous error reporting due to the way it is called from Oberon.Loop:
Project Oberon sets 'res := 5' in this case, "Unknown command" in EO, which seems appropriate and useful:
Oberon.Call:
Code: Select all
PROCEDURE Call* (name: ARRAY OF CHAR; VAR res: INTEGER);
(* .. *)
BEGIN i := 0; ch := name[0];
WHILE (ch # ".") & (ch # 0X) DO Mname[i] := ch; INC(i); ch := name[i] END ;
IF ch = "." THEN
(* .. *)
END
END Call;
Code: Select all
(* .. *)
GetCommand(ch);
IF Par.text.string[0] # 0X THEN
Call(Par.text.string, res);
IF res # 0 THEN
WriteError(res, Par.text.string)
END
END
(* .. *)
Code: Select all
PROCEDURE Call* (name: ARRAY OF CHAR; VAR res: INTEGER);
(* .. *)
BEGIN i := 0; ch := name[0];
(* .. *)
IF ch = "." THEN
(* .. * )
ELSE res := 5
END
END Call;