]> git.ipfire.org Git - thirdparty/gcc.git/commit
cobol: Plug memory leak caused by intermediate_e stack-frame variables. [PR119521]
authorBob Dubner <rdubner@symas.com>
Wed, 2 Apr 2025 16:18:08 +0000 (12:18 -0400)
committerRobert Dubner <rdubner@symas.com>
Wed, 2 Apr 2025 18:40:14 +0000 (14:40 -0400)
commit29ac3adb8f72ecbe734d535b1015fe8b411316cb
tree9893c307e448d93ff49206e2a168f994e3e4d5ae
parenta2e03736fc932ef613ad01a9499126cbaa538bf8
cobol: Plug memory leak caused by intermediate_e stack-frame variables. [PR119521]

COBOL variables with attribute intermediate_e are being allocated on
the stack frame, but their data was assigned using malloc(), without
a corresponding call to free().  For numerics, the problem is solved
with a fixed allocation of sixteen bytes for the cblc_field_t::data
member (sixteen is big enough for all data types) and with a fixed
allocation of 8,192 bytes for the alphanumeric type.

In use, the intermediate numeric data types are "shrunk" to the minimum
applicable size.  The intermediate alphanumerics, generally used as
destination targets for functions, are trimmed as well.

gcc/cobol

PR cobol/119521
* genapi.cc: (parser_division): Change comment.
(parser_symbol_add): Change intermediate_t handling.
* parse.y: Multiple changes to new_alphanumeric() calls.
* parse_ante.h: Establish named constant for date function
calls.  Change declaration of new_alphanumeric() function.
* symbols.cc: (new_temporary_impl): Use named constant
for default size of temporary alphanumerics.
* symbols.h: Establish MAXIMUM_ALPHA_LENGTH constant.

libgcobol

PR cobol/119521
* intrinsic.cc: (__gg__reverse): Trim final result for intermediate_e.
* libgcobol.cc: (__gg__adjust_dest_size): Abort on attempt to increase
the size of a result.  (__gg__module_name): Formatting.
__gg__reverse(): Resize only intermediates
gcc/cobol/genapi.cc
gcc/cobol/parse.y
gcc/cobol/parse_ante.h
gcc/cobol/symbols.cc
gcc/cobol/symbols.h
libgcobol/intrinsic.cc
libgcobol/libgcobol.cc