From b350a95717ac04a0bed1d836a0b90c94724dc597 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 May 2013 13:45:15 +1000 Subject: 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 Reviewed-by: Ping Cheng --- 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; } -- cgit v1.2.3