diff --git a/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp b/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp index 69f6ad31598a8ed35c2f5d9e34867121f98a0cb2..bf8db70992687678f4c38d63dbf6967c737baa49 100644 --- a/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp +++ b/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp @@ -73,7 +73,7 @@ Java_com_huawei_boostkit_spark_serialize_ShuffleDataSerializerUtils_columnarShuf spark::VecBatch* vecBatch = reinterpret_cast(address); int32_t vecCount = vecBatch->veccnt(); int32_t rowCount = vecBatch->rowcnt(); - omniruntime::vec::BaseVector* vecs[vecCount]; + omniruntime::vec::BaseVector* vecs[vecCount]{}; JNI_FUNC_START jint *typeIdArrayElements = env->GetIntArrayElements(typeIdArray, NULL); diff --git a/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h b/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h index 23fc600398a056b36f06f9a23c730a12336cc900..53854334110fa131ce26618a9fac07960137f638 100644 --- a/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h +++ b/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h @@ -57,9 +57,16 @@ jmethodID GetMethodID(JNIEnv* env, jclass this_class, const char* name, const ch return 0; \ } +/** + * Note: Some vectors may be nullptr if allocation failed + * (e.g., off-heap memory limit exceeded -> MEM_CAP_EXCEEDED). + */ #define JNI_FUNC_END_WITH_VECTORS(exceptionClass, vectors) \ } catch (const std::exception &e) { \ for (auto vec : vectors) { \ + if (vec == nullptr) { \ + continue; \ + } \ delete vec; \ } \ env->ThrowNew(runtimeExceptionClass, e.what()); \