When hotplugging the first tool (usually the stylus) changes pInfo->name to
the name + tool name. Thus, free the original one.

And strdup the oldname so we can unconditially free it, regardless of
whether we changed the actual device name or not.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/wcmConfig.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 3ba830b..1955661 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -513,7 +513,7 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
        WacomDevicePtr priv = NULL;
        WacomCommonPtr common = NULL;
        char            *type, *device;
-       const char      *oldname;
+       char            *oldname = NULL;
        int             need_hotplug = 0, is_dependent = 0;
 
        gWacomModule.wcmDrv = drv;
@@ -563,7 +563,7 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
 
        common->debugLevel = xf86SetIntOption(pInfo->options,
                                              "CommonDBG", common->debugLevel);
-       oldname = pInfo->name;
+       oldname = strdup(pInfo->name);
 
        if (wcmIsHotpluggedDevice(pInfo))
                is_dependent = 1;
@@ -574,6 +574,7 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
                char *new_name;
                if (asprintf(&new_name, "%s %s", pInfo->name, type) == -1)
                        new_name = strdup(pInfo->name);
+               free(pInfo->name);
                pInfo->name = priv->name = new_name;
        }
 
@@ -612,6 +613,7 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
                wcmLinkTouchAndPen(pInfo);
 
        free(type);
+       free(oldname);
 
        return Success;
 
@@ -627,6 +629,7 @@ SetupProc_fail:
        }
 
        free(type);
+       free(oldname);
        return BadMatch;
 }
 
-- 
1.8.1.4


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to