devimgr: fix string operation of device's name and identifier 40/271440/1 accepted/tizen/unified/20220222.034344 submit/tizen/20220221.233105
authorduna.oh <duna.oh@samsung.com>
Sun, 20 Feb 2022 23:00:17 +0000 (08:00 +0900)
committerduna.oh <duna.oh@samsung.com>
Mon, 21 Feb 2022 08:51:10 +0000 (17:51 +0900)
Change-Id: I8b0aa3e7ae66832691e4a98bdf4bf86784d21193

src/bin/e_devicemgr_input.c
src/bin/e_input_inputs.c

index 6c656cfb36af82f133337ab82936e2a32646722c..8fbd242232204b0360737120e341262031dff0a0 100644 (file)
@@ -185,13 +185,20 @@ failed:
 static void
 _e_devicemgr_input_device_add(const char *name, const char *identifier, const char *seatname, Ecore_Device_Class clas, Ecore_Device_Subclass subclas)
 {
-   E_Devicemgr_Input_Device *dev;
+   E_Devicemgr_Input_Device *dev = NULL;
    Eina_List *l;
    int current_touch_count = -1;
 
+   EINA_SAFETY_ON_NULL_RETURN(name);
+   EINA_SAFETY_ON_NULL_RETURN(identifier);
+
    EINA_LIST_FOREACH(e_devicemgr->device_list, l, dev)
      {
-        if ((dev->clas == clas) && (!strcmp(dev->identifier, identifier)))
+        if (!dev->name) continue;
+        if (!dev->identifier) continue;
+        if ((dev->clas == clas) && (dev->subclas == subclas) &&
+            (!strcmp(dev->name, name)) &&
+            (!strcmp(dev->identifier, identifier)))
           {
              return;
           }
@@ -243,14 +250,19 @@ _e_devicemgr_input_device_add(const char *name, const char *identifier, const ch
 static void
 _e_devicemgr_input_device_del(const char *name, const char *identifier, const char *seatname, Ecore_Device_Class clas, Ecore_Device_Subclass subclas)
 {
-   E_Devicemgr_Input_Device *dev;
+   E_Devicemgr_Input_Device *dev = NULL;
    Eina_List *l;
 
+   EINA_SAFETY_ON_NULL_RETURN(name);
+   EINA_SAFETY_ON_NULL_RETURN(identifier);
+
    EINA_LIST_FOREACH(e_devicemgr->device_list, l, dev)
      {
+        if (!dev->name) continue;
+        if (!dev->identifier) continue;
         if ((dev->clas == clas) && (dev->subclas == subclas) &&
-            (dev->name && (!strcmp(dev->name, name))) &&
-            (dev->identifier && (!strcmp(dev->identifier, identifier))))
+            (!strcmp(dev->name, name)) &&
+            (!strcmp(dev->identifier, identifier)))
           break;
      }
    if (!dev)
index f9412cda273ccc9d836971b0eef7df081a50941d..d91fcb8e56fe1bcae0e65dd2489361df96e1239b 100644 (file)
@@ -70,15 +70,19 @@ _e_input_ecore_device_event(Ecore_Device *dev, Eina_Bool flag)
 {
    Ecore_Event_Device_Info *e;
    E_Input *e_input;
+   const char *name, *identifier;
+
+   if (!(name = ecore_device_name_get(dev))) return;
+   if (!(identifier = ecore_device_identifier_get(dev))) return;
 
    if (!(e = calloc(1, sizeof(Ecore_Event_Device_Info)))) return;
 
    e_input = e_input_get();
 
    e->window = e_input?e_input->window:(Ecore_Window)0;
-   e->name = eina_stringshare_add(ecore_device_name_get(dev));
-   e->identifier = eina_stringshare_add(ecore_device_identifier_get(dev));
-   e->seatname = eina_stringshare_add(ecore_device_name_get(dev));
+   e->name = eina_stringshare_add(name);
+   e->identifier = eina_stringshare_add(identifier);
+   e->seatname = eina_stringshare_add(name);
    e->clas = ecore_device_class_get(dev);
    e->subclas = ecore_device_subclass_get(dev);
 
@@ -159,7 +163,7 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
         EINA_LIST_FOREACH(dev_list, l, dev)
           {
              if (!dev) continue;
-             identifier = ecore_device_description_get(dev);
+             identifier = ecore_device_identifier_get(dev);
              if (!identifier) continue;
              if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
                return EINA_FALSE;
@@ -220,7 +224,7 @@ _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
    EINA_LIST_FOREACH(dev_list, l, dev)
       {
          if (!dev) continue;
-         identifier = ecore_device_description_get(dev);
+         identifier = ecore_device_identifier_get(dev);
          if (!identifier) continue;
          if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
            {
@@ -304,7 +308,7 @@ _e_input_device_remove(E_Input_Evdev *edev)
              EINA_LIST_FREE(edev->ecore_dev_list, data)
                {
                   WRN("Invalid device is left. name: %s, identifier: %s, clas: %s\n",
-                      ecore_device_name_get(data), ecore_device_description_get(data),
+                      ecore_device_name_get(data), ecore_device_identifier_get(data),
                       _e_input_ecore_device_class_to_string(ecore_device_class_get(data)));
                   ecore_device_unref(data);
                   ecore_device_del(data);