From 50e6c50492b986a1b99b26d158a0e2462662b817 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 14 Dec 2019 23:05:04 +0300 Subject: [PATCH] fix possible trap with directive NEW --- src/generic/Dev/Mod/CPR.cp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/generic/Dev/Mod/CPR.cp b/src/generic/Dev/Mod/CPR.cp index 03c3fe4..1069215 100644 --- a/src/generic/Dev/Mod/CPR.cp +++ b/src/generic/Dev/Mod/CPR.cp @@ -84,12 +84,12 @@ MODULE DevCPR; END END Get; - PROCEDURE New (IN name: DevCPT.Name; val: BOOLEAN): Selector; + PROCEDURE New (IN name: DevCPT.Name): Selector; VAR s: Selector; BEGIN s := scope; WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END; - IF s.next = NIL THEN NEW(s.next); s.next.name := name$; s.next.val := val + IF s.next = NIL THEN NEW(s.next); s.next.name := name$; s.next.val := FALSE ELSE err(1) END; RETURN s.next @@ -210,20 +210,21 @@ MODULE DevCPR; Get(sym); IF sym = new THEN Get(sym); - IF sym = ident THEN s := New(name, FALSE); Get(sym) + IF sym = ident THEN + s := New(name); Get(sym); + IF (sym = plus) OR (sym = minus) THEN + s.val := sym = plus; Get(sym) + END ELSE err(48) - END; + END + ELSIF sym = ident THEN + s := Old(name); Get(sym); IF (sym = plus) OR (sym = minus) THEN s.val := sym = plus; Get(sym) + ELSE err(41) END ELSIF sym = error THEN IF Printable() THEN err(501) END; Get(sym) - ELSIF sym = ident THEN - Get(sym); - IF sym = plus THEN Old(name).val := TRUE; Get(sym) - ELSIF sym = minus THEN Old(name).val := FALSE; Get(sym) - ELSE err(41) - END ELSIF sym = if THEN Get(sym); Expression(val); If(val); IF sym = then THEN Get(sym) -- 2.29.2