From f767eb70d04103233d1b68ee2c7b673d0b0a31bd Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Wed, 25 Jul 2018 15:27:18 +0200 Subject: [PATCH] symbolic exports: fix ReleaseStringUTFChars call on null pointer In case that no export_name is passed to one of the PM_Export..., PS_Export.... functions, ReleaseStringUTFChars() would be called even though there was no previous call to GetStringUTFChars(), leading to a SEGFAULT. This is for robustness, PRISM always passes an export_name string. --- prism/src/mtbdd/PM_ExportLabels.cc | 2 +- prism/src/mtbdd/PM_ExportMatrix.cc | 2 +- prism/src/mtbdd/PM_ExportVector.cc | 2 +- prism/src/sparse/PS_ExportMatrix.cc | 2 +- prism/src/sparse/PS_ExportSubMDP.cc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/prism/src/mtbdd/PM_ExportLabels.cc b/prism/src/mtbdd/PM_ExportLabels.cc index 46d80a12..30f47c6a 100644 --- a/prism/src/mtbdd/PM_ExportLabels.cc +++ b/prism/src/mtbdd/PM_ExportLabels.cc @@ -127,7 +127,7 @@ jstring fn // filename // close file, etc. if (export_file) fclose(export_file); - env->ReleaseStringUTFChars(na, export_name); + if (na) env->ReleaseStringUTFChars(na, export_name); return 0; } diff --git a/prism/src/mtbdd/PM_ExportMatrix.cc b/prism/src/mtbdd/PM_ExportMatrix.cc index 5ac202e8..eb5b22b6 100644 --- a/prism/src/mtbdd/PM_ExportMatrix.cc +++ b/prism/src/mtbdd/PM_ExportMatrix.cc @@ -86,7 +86,7 @@ jstring fn // filename // close file, etc. if (export_file) fclose(export_file); - env->ReleaseStringUTFChars(na, export_name); + if (na) env->ReleaseStringUTFChars(na, export_name); return 0; } diff --git a/prism/src/mtbdd/PM_ExportVector.cc b/prism/src/mtbdd/PM_ExportVector.cc index 0f145497..3b1ed800 100644 --- a/prism/src/mtbdd/PM_ExportVector.cc +++ b/prism/src/mtbdd/PM_ExportVector.cc @@ -76,7 +76,7 @@ jstring fn // filename // close file, etc. if (export_file) fclose(export_file); - env->ReleaseStringUTFChars(na, export_name); + if (na) env->ReleaseStringUTFChars(na, export_name); return 0; } diff --git a/prism/src/sparse/PS_ExportMatrix.cc b/prism/src/sparse/PS_ExportMatrix.cc index e2a80eb6..07e3ee14 100644 --- a/prism/src/sparse/PS_ExportMatrix.cc +++ b/prism/src/sparse/PS_ExportMatrix.cc @@ -162,7 +162,7 @@ jstring fn // filename // close file, etc. if (export_file) fclose(export_file); - env->ReleaseStringUTFChars(na, export_name); + if (na) env->ReleaseStringUTFChars(na, export_name); // catch exceptions: return (undocumented) error code for memout } catch (std::bad_alloc e) { diff --git a/prism/src/sparse/PS_ExportSubMDP.cc b/prism/src/sparse/PS_ExportSubMDP.cc index 007438e7..0c37d840 100644 --- a/prism/src/sparse/PS_ExportSubMDP.cc +++ b/prism/src/sparse/PS_ExportSubMDP.cc @@ -120,7 +120,7 @@ jstring fn // filename // close file, etc. if (export_file) fclose(export_file); - env->ReleaseStringUTFChars(na, export_name); + if (na) env->ReleaseStringUTFChars(na, export_name); // catch exceptions: return (undocumented) error code for memout } catch (std::bad_alloc e) {