Fix segmentation fault 56/237956/2
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Tue, 7 Jul 2020 11:45:31 +0000 (11:45 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Tue, 7 Jul 2020 11:58:13 +0000 (11:58 +0000)
- Fix wrong pointer casting
- From API reference, get property value must be release using free

Change-Id: Ibf8643e497a2a89bc47bd81b598e879f99169bc9
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
src/update_control.c

index 0b67ac6389e75acaea8888df7974980867fa98b5..e406ff25c613dba5f70ebe75aeb24dae9a245e5c 100644 (file)
@@ -259,8 +259,14 @@ API int update_control_get_property(update_control_property_e property, void **v
                        _E("Failed to get result : %d", status);
                        return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
                }
-
                _I("Success to get result : %d", status);
+
+               *value = malloc(sizeof(int));
+               if (!*value) {
+                       _E("Failed to allocate memory");
+                       return UPDATE_CONTROL_ERROR_OUT_OF_MEMORY;
+               }
+
                *(int *)(*value) = status;
                return UPDATE_CONTROL_ERROR_NONE;
        default: