MONDAY, JULY 6, 2026
cobol
COBOL: Prevent crash on invalid refmod literal (PR126104)
Fixes a crash in the COBOL compiler when encountering invalid `refmod` literals.
This commit addresses a crash in the COBOL compiler that occurred when processing invalid refmod literals. A specific check in literal_refmod_valid within parse.y has been modified to prevent dereferencing a NULL pointer, resolving the issue reported in PR126104.
In Details
In gcc/cobol/parse.y, the literal_refmod_valid function previously failed to check for a NULL pointer before attempting to dereference it when validating refmod literals, causing a crash. This commit adds the necessary NULL check, fixing the bug reported in PR126104.
For Context
- refmod
- Likely refers to a 'referential modifier' or a similar construct within COBOL syntax, used for qualifying certain types of literals or references. The exact meaning depends on the specific COBOL dialect and context.
- literal
- A fixed value represented directly in source code, such as a number (e.g.,
123), a string (e.g.,'hello'), or a boolean (TRUE). - parse.y
- A file typically containing grammar rules for a parser generator like Bison (or Yacc), used here for the COBOL front-end to define the language's syntax.
- NULL pointer
- A pointer that does not point to any valid memory location. In C/C++, it's often represented by
NULLor0.