Skip to content

Commit 32ec675

Browse files
committed
fix in ooc Strings modules to prevent index out of range error.
1 parent bc8adf7 commit 32ec675

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/library/ooc/oocStrings.Mod

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ PROCEDURE Length* (stringVal: ARRAY OF CHAR): INTEGER;
6363
i: INTEGER;
6464
BEGIN
6565
i := 0;
66-
WHILE (stringVal[i] # 0X) DO
66+
(* note from noch:
67+
original ooc code below, commented out, leads to
68+
index out of range runtime error
69+
WHILE (stringVal[i] # 0X) DO *)
70+
WHILE ((i < LEN(stringVal)) & (stringVal[i] # 0X)) DO
6771
INC (i)
6872
END;
6973
RETURN i

src/library/ooc2/ooc2Strings.Mod

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ PROCEDURE Length* (stringVal: ARRAY OF CHAR): INTEGER;
5959
i: INTEGER;
6060
BEGIN
6161
i := 0;
62-
WHILE (stringVal[i] # 0X) DO
62+
(* note from noch:
63+
this original ooc code crashes with index out of range
64+
because it doesn't expect a string which has no 0X character
65+
so i had to change it
66+
WHILE (stringVal[i] # 0X) DO *)
67+
WHILE ((i < LEN(stringVal)) & (stringVal[i] # 0X)) DO
6368
INC (i)
6469
END;
6570
RETURN i

0 commit comments

Comments
 (0)