Skip to content

Commit

Permalink
FIXED: Illegal use of SWI-Prolog API
Browse files Browse the repository at this point in the history
Code as modifying predicate arguments.
  • Loading branch information
JanWielemaker committed May 30, 2024
1 parent 7815969 commit 59d2083
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/main/c/jpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4811,27 +4811,26 @@ jni_jref_to_term_plc(term_t jref, /* +term: JRef to a org.jpl7.Term instance */
;
}

static bool
jni_get_default_jvm_opts_1(term_t args, int i, char **jvm_xia)
{ term_t tp = PL_new_term_ref();

if (jvm_xia[i] == NULL)
{ return PL_unify_nil(args);
} else
{ return PL_unify_list(args, tp, args) &&
PL_unify_term(tp, PL_ATOM, PL_new_atom(jvm_xia[i])) &&
jni_get_default_jvm_opts_1(args, i + 1, jvm_xia);
}
}

static foreign_t
jni_get_jvm_opts(term_t args, /* -list(atom): the current default JVM
initialisation options */
char **jvm_xia)
{ if (jvm_xia == NULL)
{ return FALSE;
} else
{ return jni_get_default_jvm_opts_1(args, 0, jvm_xia);
{ term_t tail = PL_copy_term_ref(args);
term_t tp = PL_new_term_ref();

if ( !tail || !tp )
return FALSE;

for(size_t i=0; jvm_xia[i]; i++)
{ if ( !PL_unify_list(tail, tp, tail) ||
!PL_unify_term(tp, PL_CHARS, jvm_xia[i]) )
return FALSE;
}

return PL_unify_nil(tail);
}
}

Expand Down

0 comments on commit 59d2083

Please sign in to comment.