Add core abi capability
[sdk/target/sdbd.git] / src / default_plugin_event.c
index 787c3f4..37aa39a 100644 (file)
@@ -120,6 +120,11 @@ int get_lock_state ( parameters* in, parameters* out )
 
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+    if (out->array_of_parameter == NULL) {
+        out->number_of_parameter = 0;
+        PLUGIN_LOG("failed to allocate memory for the parameter\n");
+        return PLUGIN_CMD_FAIL;
+    }
     out->array_of_parameter[0].type = type_int32;
     out->array_of_parameter[0].v_int32 = ( plugin_pwlocked() == 1 ) ? PLUGIN_RET_ON : PLUGIN_RET_OFF;
 
@@ -132,8 +137,17 @@ static void pwlock_cb ( keynode_t *key, void* data )
     int pwlocked = plugin_pwlocked();
 
     parameters* out = ( parameters* ) malloc ( sizeof ( parameters ) );
+    if (out == NULL) {
+        PLUGIN_LOG("failed to allocate memory for the parameter\n");
+        return;
+    }
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+    if (out->array_of_parameter == NULL) {
+        PLUGIN_LOG("failed to allocate memory for the parameter\n");
+        free(out);
+        return;
+    }
     out->array_of_parameter[0].type = type_int32;
     out->array_of_parameter[0].v_int32 = ( pwlocked == 1 ) ? PLUGIN_RET_ON : PLUGIN_RET_OFF;