From e508a7eb3c98857c774a449f41bd64434f9a2514 Mon Sep 17 00:00:00 2001 From: jaehyun Cho Date: Wed, 1 Feb 2017 20:07:35 +0900 Subject: [PATCH] Fix defects detected by static analysis Change-Id: I43d5400da6e7fd2ee6265c04c36ba59e6ab05478 Signed-off-by: jaehyun Cho Reviewed-on: https://gerrit.iotivity.org/gerrit/16953 Reviewed-by: Jaehong Jo Tested-by: jenkins-iotivity Reviewed-by: Ashok Babu Channa Reviewed-by: Dan Mihai --- java/jni/JniOcPlatform.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/java/jni/JniOcPlatform.cpp b/java/jni/JniOcPlatform.cpp index 5784c5f..83e4c7d 100644 --- a/java/jni/JniOcPlatform.cpp +++ b/java/jni/JniOcPlatform.cpp @@ -1523,7 +1523,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0( jstring jStr = (jstring)env->GetObjectArrayElement(jDeviceTypes, i); if (!jStr) { - delete deviceInfo.deviceName; + delete[] deviceInfo.deviceName; ThrowOcException(OC_STACK_INVALID_PARAM, "device type cannot be null"); return; } @@ -1531,7 +1531,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0( OCResourcePayloadAddStringLL(&deviceInfo.types, env->GetStringUTFChars(jStr, nullptr)); if (env->ExceptionCheck()) { - delete deviceInfo.deviceName; + delete[] deviceInfo.deviceName; return; } @@ -1548,7 +1548,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0( { OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo); - delete deviceInfo.deviceName; + delete[] deviceInfo.deviceName; if (OC_STACK_OK != result) { @@ -1668,17 +1668,17 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0( { OCStackResult result = OCPlatform::registerPlatformInfo(platformInfo); - delete platformInfo.platformID; - delete platformInfo.manufacturerName; - delete platformInfo.manufacturerUrl; - delete platformInfo.modelNumber; - delete platformInfo.dateOfManufacture; - delete platformInfo.platformVersion; - delete platformInfo.operatingSystemVersion; - delete platformInfo.hardwareVersion; - delete platformInfo.firmwareVersion; - delete platformInfo.supportUrl; - delete platformInfo.systemTime; + delete[] platformInfo.platformID; + delete[] platformInfo.manufacturerName; + delete[] platformInfo.manufacturerUrl; + delete[] platformInfo.modelNumber; + delete[] platformInfo.dateOfManufacture; + delete[] platformInfo.platformVersion; + delete[] platformInfo.operatingSystemVersion; + delete[] platformInfo.hardwareVersion; + delete[] platformInfo.firmwareVersion; + delete[] platformInfo.supportUrl; + delete[] platformInfo.systemTime; if (OC_STACK_OK != result) { -- 2.7.4