Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cob_call_with_exception_check
Browse files Browse the repository at this point in the history
ddeclerck committed Dec 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent c0d64ad commit 02f7de6
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libcob/common.c
Original file line number Diff line number Diff line change
@@ -297,6 +297,8 @@ static const char *cob_last_progid = NULL;
static cob_global *cobglobptr = NULL;
static cob_settings *cobsetptr = NULL;

static int inhibit_call_exit_handlers_and_terminate = 0;

static int last_exception_code; /* Last exception: code */
static int active_error_handler = 0;

@@ -3001,6 +3003,9 @@ cob_get_pointer (const void *srcptr)
static void
call_exit_handlers_and_terminate (void)
{
if (inhibit_call_exit_handlers_and_terminate != 0) {
return;
}
if (exit_hdlrs != NULL) {
struct exit_handlerlist *h = exit_hdlrs;
while (h != NULL) {
@@ -10014,17 +10019,20 @@ cob_common_init (void *setptr)
errors (-1), hard errors (-2) or signals (-3) */
int
cob_call_with_exception_check (const char *name, const int argc, void **argv)
{
{
inhibit_call_exit_handlers_and_terminate = 1;
#ifndef COB_WITHOUT_JMP
int ret;
return_jmp_buffer_set = 1;
ret = setjmp (return_jmp_buf);
if (ret) {
return_jmp_buffer_set = 0;
inhibit_call_exit_handlers_and_terminate = 0;
return ret;
}
#endif
exit_code = cob_call (name, argc, argv);
inhibit_call_exit_handlers_and_terminate = 0;
return 0;
}

3 changes: 3 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
@@ -2054,7 +2054,10 @@ COB_EXPIMP void *cob_call_field (const cob_field *,
COB_EXPIMP void cob_cancel_field (const cob_field *,
const struct cob_call_struct *);
COB_EXPIMP void cob_cancel (const char *);

/* When using this function, modules will not be unloaded until you manually call cob_tidy */
COB_EXPIMP int cob_call_with_exception_check (const char*, const int, void **);

COB_EXPIMP int cob_call (const char *, const int, void **);
COB_EXPIMP int cob_func (const char *, const int, void **);

0 comments on commit 02f7de6

Please sign in to comment.