Set unused OCDeviceInfo struct fields to NULL
authorljsachs <larry.j.sachs@intel.com>
Mon, 8 Aug 2016 21:25:24 +0000 (14:25 -0700)
committerUze Choi <uzchoi@samsung.com>
Thu, 8 Sep 2016 04:30:32 +0000 (04:30 +0000)
Java DeviceInfo never uses the optional OCDeviceInfo fields,
these must be set to NULL to avoid potential corrupt data.

Change-Id: I7eda3be60d17591ab6169c0d487784c474f6325d
Signed-off-by: ljsachs <larry.j.sachs@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10165
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
android/android_api/base/jni/JniOcPlatform.cpp

index da0aea3..5f0faa5 100644 (file)
@@ -1627,10 +1627,10 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0(
     }
 
     OCDeviceInfo deviceInfo;
+    memset(&deviceInfo, 0, sizeof(deviceInfo));
     try
     {
         DuplicateString(&deviceInfo.deviceName, env->GetStringUTFChars(jDeviceName, nullptr));
-        deviceInfo.types = NULL;
 
         jsize len = env->GetArrayLength(jDeviceTypes);
         for (jsize i = 0; i < len; ++i)