util: timer: Add exception handling when calloc is failed 29/316929/1 accepted/tizen/unified/20240903.110740 accepted/tizen/unified/dev/20240910.111523 accepted/tizen/unified/x/20240904.025256
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 30 Aug 2024 09:18:02 +0000 (18:18 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 30 Aug 2024 09:19:25 +0000 (18:19 +0900)
Add exception handling when calloc is failed to prevent segmentation
fault.

Change-Id: I5a7a5733bd744acecc10a950f60c8925711354ad
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/util/timer.c

index 26aad8209f4db864865d83e8f7f4bae6d276aa49..ef868c8003d8d45b226d02a6afbdcc8ec5160d82 100644 (file)
@@ -172,6 +172,11 @@ struct udev_monitor *add_uevent_handler(
 
        /* Add new uevent-based handler to uevent_list */
        uevent_data = calloc(1, sizeof(*uevent_data));
+       if (!uevent_data) {
+               _E("'failed to allocate the memory of uevent_data\n");
+               goto err_udev_monitor_fd;
+       }
+
        uevent_data->udev_monitor = udev_monitor;
        uevent_data->fd = gfd;
        g_uevent_list = g_list_append(g_uevent_list, (gpointer)uevent_data);