battery: add NULL check routine for input parameter 26/75026/1 accepted/tizen/common/20160617.121323 accepted/tizen/ivi/20160617.083348 accepted/tizen/mobile/20160617.083147 accepted/tizen/tv/20160617.083050 accepted/tizen/wearable/20160617.083139 submit/tizen/20160616.101144
authortaeyoung <ty317.kim@samsung.com>
Thu, 16 Jun 2016 10:07:15 +0000 (19:07 +0900)
committertaeyoung <ty317.kim@samsung.com>
Thu, 16 Jun 2016 10:08:49 +0000 (19:08 +0900)
- App crash issue occurs when the input parameter is NULL.
  Thus NULL check routine is added.

Change-Id: I34321c2ebb5c630c25afb8972d448db234769bc3
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/battery.c

index d65ed3d..f1f5217 100644 (file)
@@ -170,6 +170,9 @@ int device_battery_get_health(device_battery_health_e *health)
        int ret;
        size_t len;
 
+       if (!health)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
        ret = device_battery_get_info(&info);
        if (ret != DEVICE_ERROR_NONE) {
                _E("Failed to get battery info (%d)", ret);
@@ -199,6 +202,9 @@ int device_battery_get_power_source(device_battery_power_source_e *source)
        int ret;
        size_t len;
 
+       if (!source)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
        ret = device_battery_get_info(&info);
        if (ret != DEVICE_ERROR_NONE) {
                _E("Failed to get battery info (%d)", ret);
@@ -255,6 +261,9 @@ int device_battery_get_status(device_battery_status_e *status)
        int ret;
        size_t len;
 
+       if (!status)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
        ret = device_battery_get_info(&info);
        if (ret != DEVICE_ERROR_NONE) {
                _E("Failed to get battery info (%d)", ret);