Skip to content

Commit

Permalink
Fix cob_call_with_exception_check
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Dec 13, 2023
1 parent c0d64ad commit 52f4cb5
Show file tree
Hide file tree
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
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
{
{
#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
inhibit_call_exit_handlers_and_terminate = 1;
exit_code = cob_call (name, argc, argv);
inhibit_call_exit_handlers_and_terminate = 0;
return 0;
}

Expand Down
3 changes: 3 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 **);

Expand Down

0 comments on commit 52f4cb5

Please sign in to comment.