From 703ac357357858351b27cb33b12830193e591282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Wed, 20 Jan 2016 23:16:04 +0000 Subject: [PATCH] fix error crash while constructing error term --- C/errors.c | 18 ++++++++++-------- C/stack.c | 2 ++ packages/jpl/CMakeLists.txt | 7 +++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/C/errors.c b/C/errors.c index f409e17d3..6937a44ed 100755 --- a/C/errors.c +++ b/C/errors.c @@ -361,7 +361,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno, CELL nt[3]; Functor fun; bool serious; - Term tf, error_t, comment, culprit; + Term tf, error_t, comment, culprit = TermNil; char *format; char s[MAXPATHLEN]; @@ -527,6 +527,8 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno, } if (type != ABORT_EVENT) { + Term location; + /* This is used by some complex procedures to detect there was an error */ if (IsAtomTerm(nt[0])) { strncpy(LOCAL_ErrorSay, (char *) RepAtom(AtomOfTerm(nt[0]))->StrOfAE, @@ -538,14 +540,14 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno, MAX_ERROR_MSG_SIZE); LOCAL_ErrorMessage = LOCAL_ErrorSay; } + nt[1] = TermNil; switch (type) { case RESOURCE_ERROR_HEAP: case RESOURCE_ERROR_STACK: case RESOURCE_ERROR_TRAIL: comment = MkAtomTerm(Yap_LookupAtom(tmpbuf)); - default: - nt[1] = TermNil; - if (comment != TermNil) + default: + if (comment != TermNil) nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("i")), comment), nt[1]); if (file && function) { @@ -557,12 +559,12 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno, nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]); } - if ((culprit = Yap_pc_location(P, B, ENV)) != TermNil) { - nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), culprit), + if ((location = Yap_pc_location(P, B, ENV)) != TermNil) { + nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location), nt[1]); } - if ((culprit = Yap_env_location(CP, B, ENV, 0)) != TermNil) { - nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), culprit), + if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) { + nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location), nt[1]); } } diff --git a/C/stack.c b/C/stack.c index 88e99f2cc..67b0539fa 100644 --- a/C/stack.c +++ b/C/stack.c @@ -1924,6 +1924,8 @@ static Term build_bug_location(yamop *codeptr, PredEntry *pe) { } else p[4] = MkIntTerm(0); } + } else { + p[4] = MkIntTerm(0); } } } else if (pe->OpcodeOfPred == UNDEF_OPCODE) { diff --git a/packages/jpl/CMakeLists.txt b/packages/jpl/CMakeLists.txt index 8c23070cc..4494c3e79 100644 --- a/packages/jpl/CMakeLists.txt +++ b/packages/jpl/CMakeLists.txt @@ -3,8 +3,7 @@ set (JPL_SOURCES src/c/jpl.c) -macro_optional_find_package(Java ON) -find_package(Java ) +find_package(Java COMPONENTS Runtime Development) # find_package(Java COMPONENTS Development) # find_package(Java COMPONENTS Runtime) #find_package(JavaLibs) @@ -12,7 +11,7 @@ macro_log_feature (Java_Development_FOUND "Java" "Use Java System" "http://www.java.org" FALSE) -if (Java_FOUND) +if (Java_Development_FOUND) # Java_JAVA_EXECUTABLE = the full path to the Java runtime # Java_JAVAC_EXECUTABLE = the full path to the Java compiler # Java_JAVAH_EXECUTABLE = the full path to the Java header generator @@ -79,4 +78,4 @@ if (Java_FOUND) ) endif(JNI_FOUND) -endif (Java_FOUND) +endif (Java_Development_FOUND)