[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] segmentation fault after ACCEPT ... FROM ARGUMENT-VALU
From: |
Franklin Ankum |
Subject: |
[open-cobol-list] segmentation fault after ACCEPT ... FROM ARGUMENT-VALUE |
Date: |
Fri Feb 11 02:45:06 2005 |
I found a bug in libcob/termio.c line 309
cob_accept_arg_value (cob_field *f)
{
if ( current_arg > cob_argc ) {
return;
}
cob_memcpy (f, cob_argv[current_arg], strlen
(cob_argv[current_arg]));
current_arg++;
}
Here is the Cobol-Code to get the Segmentation fault:
MOVE SPACE TO WRK-ARGUMENT
ACCEPT WRK-ARGUMENT FROM ARGUMENT-VALUE
PERFORM WITH TEST BEFORE UNTIL WRK-ARGUMENT = SPACE
DISPLAY WRK-ARGUMENT
MOVE SPACE TO WRK-ARGUMENT
ACCEPT WRK-ARGUMENT FROM ARGUMENT-VALUE
END-PERFORM
the Problem is a simple 0 - 1 Problem:
current_arg is the index of the argument starting at 0
and cob_argc is the number of arguments.
so current_arg may never be greater than cob_argc -1
Changing line 306 to "if ( current_arg >= cob_argc )" solves the problem.
In MicroFocus Cobol the first argument is not the programname it self, but
really the first argument following the programname,
would this be a bug or is this the normal behaviour?
Franklin
- [open-cobol-list] segmentation fault after ACCEPT ... FROM ARGUMENT-VALUE,
Franklin Ankum <=