e_input_backend: Fix deref of null pointer 50/321350/1
authorTaeHyeon Jeong <thyeon.jeong@samsung.com>
Wed, 19 Mar 2025 05:58:46 +0000 (14:58 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 19 Mar 2025 06:37:22 +0000 (15:37 +0900)
- Passing a NULL pointer to the strdup function results in undefined behavior.

Change-Id: I28b5e9262e489de09cc6bb7a958da0f7170836f4

src/bin/inputmgr/e_input_backend.c

index 22fc84fdeb8f9eb2751c14a19a1bd83b8e389d6b..d89d4600b991acb2f40f078f224c095b310f07ae 100644 (file)
@@ -379,6 +379,8 @@ _e_input_add_ecore_device(E_Input_Evdev *evdev, Ecore_Device_Class clas, Ecore_D
 
    const GList *device_list = e_device_list_get();
    const gchar *device_identifier;
+   const char *seat_name = NULL;
+
    for (GList *list = g_list_first((GList *)device_list); list; list = list->next)
      {
         E_Device *device = (E_Device *)list->data;
@@ -452,7 +454,8 @@ _e_input_add_ecore_device(E_Input_Evdev *evdev, Ecore_Device_Class clas, Ecore_D
    dev_info->evdev = evdev;
    dev_info->clas = clas;
    dev_info->subclas = subclas;
-   dev_info->seatname = strdup(e_device_seatname_get(e_dev));
+   seat_name = e_device_seatname_get(e_dev);
+   dev_info->seatname = seat_name ? strdup(seat_name) : NULL;
 
    ecore_main_loop_thread_safe_call_async(_e_input_add_ecore_device_async_cb, dev_info);