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

Fix for segault in check_argument_conformance (extracted from #109) #183

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ NEWS - user visible changes -*- outline -*-

more work in progress

* Changes that potentially effect recompilation of existing programs:

** runtime checks for invalid numerical data in emitter fields of MOVE or SET
statements are now performed only when at least one receiver field
is of category numeric or numeric-edited. This enables programming
patterns where invalid numerical data (e.g, SPACES) encode "absent"
data

* Important Bugfixes

** #904: MOVE PACKED-DECIMAL unsigned to signed led to bad sign
Expand Down
14 changes: 14 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@

2024-09-26 Fabrice Le Fessant <[email protected]>

* typeck.c (check_argument_conformance): check that param is well defined
to prevent a segfault

2024-09-25 Nicolas Berthier <[email protected]>

* typeck.c (cb_tree_is_numeric_ref_or_field)
(cb_tree_list_has_numeric_ref_or_field): new helper functions to check
whether a given item is of category numeric (edited or not)
* typeck.c (cb_emit_incompat_data_checks): use new helper function
* typeck.c (cb_emit_move, cb_emit_set_to): do not check for incompatible
data if no receiver field is of category numeric or numeric edited

2024-08-28 David Declerck <[email protected]>

* tree.c (char_to_precedence_idx, get_char_type_description, valid_char_order):
Expand Down
42 changes: 33 additions & 9 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,16 +1055,31 @@ cb_emit_list (cb_tree l)
return l;
}

static COB_INLINE COB_A_INLINE int
cb_tree_is_numeric_ref_or_field (cb_tree x, int include_numeric_edited) {
int cat;
if (!x || !CB_REF_OR_FIELD_P (x)) {
return 0;
}
cat = CB_TREE_CATEGORY (x);
return (cat == CB_CATEGORY_NUMERIC
|| (include_numeric_edited && cat == CB_CATEGORY_NUMERIC_EDITED));
}

static int
cb_tree_list_has_numeric_ref_or_field (cb_tree l) {
for (l;
l && !cb_tree_is_numeric_ref_or_field (CB_VALUE (l), 1);
l = CB_CHAIN (l));
return (l != NULL);
}

static void
cb_emit_incompat_data_checks (cb_tree x)
{
struct cb_field *f;

if (!x || x == cb_error_node) {
return;
}
if (!CB_REF_OR_FIELD_P (x)
|| CB_TREE_CATEGORY (x) != CB_CATEGORY_NUMERIC) {
if (!cb_tree_is_numeric_ref_or_field (x, 0)) {
return;
}
f = CB_FIELD_PTR (x);
Expand Down Expand Up @@ -3588,6 +3603,9 @@ check_argument_conformance (struct cb_program *program, cb_tree argument_tripple
} else {
arg_field = NULL;
}
if (!CB_FIELD_P(param)) {
return;
}
param_field = CB_FIELD_PTR(CB_VALUE(param));

/*
Expand Down Expand Up @@ -12884,8 +12902,11 @@ cb_emit_move (cb_tree src, cb_tree dsts)
return;
}

/* validate / fix-up source, if requested */
cb_emit_incompat_data_checks (src);
/* validate / fix-up source, if at least one receiver is of category
numeric */
if (cb_tree_list_has_numeric_ref_or_field (dsts)) {
cb_emit_incompat_data_checks (src);
}

/* FIXME: this is way to much to cater for sum field */
src = cb_check_sum_field (src);
Expand Down Expand Up @@ -13725,8 +13746,11 @@ cb_emit_set_to (cb_tree vars, cb_tree src)
return;
}

/* validate / fix-up source, if requested */
cb_emit_incompat_data_checks (src);
/* validate / fix-up source, if at least one receiver is of category
numeric */
if (cb_tree_list_has_numeric_ref_or_field (vars)) {
cb_emit_incompat_data_checks (src);
}

/* Emit statements. */
for (l = vars; l; l = CB_CHAIN (l)) {
Expand Down
10 changes: 10 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

2024-07-27 Chuck Haatvedt <[email protected]>

* screenio.c: In preparation for Multiple Window support
added static WINDOW pointer "mywin", all curses functions
which either implicitly or explicitly referenced the
stdscr WINDOW pointer were changed to use the window
specific functions using mywin except the getch function
remains unchanged. The wgetch function caused the mouse
not to be recognized.

2024-09-20 Chuck Haatvedt <[email protected]>

* screenio.c (cob_screen_get_all) fixed Bug #990
Expand Down
Loading
Loading