summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-05-09 13:45:15 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-05-09 13:49:10 +1000
commitb350a95717ac04a0bed1d836a0b90c94724dc597 (patch)
treee47224faef5dbb4fee366074eea94294deb25177
parent06abd7a61323034bd58e745a18f0b08723de0064 (diff)
Free the device name after reassigning
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.hutterer@who-t.net> Reviewed-by: Ping Cheng <pinglinux@gmail.com>
-rw-r--r--src/wcmConfig.c7
1 files 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;
}