Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling after increasing the array index #280

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
*
WORKING-STORAGE SECTION.
01 Filler.
05 LASTREC PIC X VALUE SPACE.
05 LASTREC PIC X VALUE SPACE.
05 DISP-SUB1 PIC 9999.
05 SUB1 PIC 99.
05 OVERLIMIT-MAX PIC S9(4) COMP VALUE 20.

01 OVERLIMIT.
03 FILLER OCCURS 20 TIMES.
Expand Down Expand Up @@ -136,7 +137,7 @@
WRITE PRINT-REC FROM HEADER-3.
WRITE PRINT-REC FROM HEADER-4.
MOVE SPACES TO PRINT-REC.
MOVE 1 TO SUB1.
MOVE 0 TO SUB1.
*
READ-NEXT-RECORD.
PERFORM READ-RECORD
Expand All @@ -162,11 +163,19 @@
*
IS-OVERLIMIT.
IF ACCT-LIMIT < ACCT-BALANCE THEN
ADD 1 TO SUB1
* Check if there is enough space in the array, in case the input
* file changes again. A handled error is easier to find and fix
* than a buffer overwrite error.
IF SUB1 > OVERLIMIT-MAX THEN
DISPLAY 'OVERFLOW TABLE OVERLIMIT'
MOVE 1000 TO RETURN-CODE
STOP RUN
END-IF
MOVE ACCT-LIMIT TO OL-ACCT-LIMIT(SUB1)
MOVE ACCT-BALANCE TO OL-ACCT-BALANCE(SUB1)
MOVE LAST-NAME TO OL-LASTNAME(SUB1)
MOVE FIRST-NAME TO OL-FIRSTNAME(SUB1)
ADD 1 TO SUB1
END-IF.
*
IS-STATE-VIRGINIA.
Expand All @@ -175,7 +184,7 @@
END-IF.
*
WRITE-OVERLIMIT.
IF SUB1 = 1 THEN
IF SUB1 = 0 THEN
MOVE OVERLIMIT-STATUS TO PRINT-REC
WRITE PRINT-REC
ELSE
Expand Down