diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-07-19 14:13:33 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-07-19 14:13:33 +1000 |
commit | 2f1a5b44f62028f2608c0c94e58154df09e9ada3 (patch) | |
tree | b91091e76517ce0f46141a443a05d5ae7ac12a17 /src | |
parent | e76e20d4d4a39e139a778411a2ed09ec35c2046e (diff) |
Don't free anything in PreInit, provide an UnInit instead.
Also fixes:
- leaking priv->buffer
- fd closure bug
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/acecad.c | 24 | ||||
-rw-r--r-- | src/acecad.h | 1 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/acecad.c b/src/acecad.c index a3326a0..6a0b347 100644 --- a/src/acecad.c +++ b/src/acecad.c @@ -126,7 +126,7 @@ _X_EXPORT InputDriverRec ACECAD = "acecad", NULL, AceCadPreInit, - NULL, + AceCadUnInit, NULL, default_options }; @@ -462,16 +462,26 @@ AceCadPreInit(InputDriverPtr drv, InputInfoPtr local, int flags) * If something went wrong, cleanup and return NULL */ SetupProc_fail: - if ((local) && (local->fd)) + return BadAlloc; +} + +static void +AceCadUnInit(InputDriverPtr drv, InputInfoPtr local, int flags) +{ + AceCadPrivatePtr priv = (AceCadPrivatePtr) (local->private); + + if (local->fd > -1) + { xf86CloseSerial (local->fd); - if ((priv) && (priv->buffer)) - XisbFree (priv->buffer); + local->fd = -1; + } + if (priv) { + if (priv->buffer) + XisbFree (priv->buffer); free (priv); - if (local) - local->private = NULL; + local->private = NULL; } - return BadAlloc; } static Bool diff --git a/src/acecad.h b/src/acecad.h index b9291c7..48fa38a 100644 --- a/src/acecad.h +++ b/src/acecad.h @@ -106,6 +106,7 @@ static Bool QueryHardware (AceCadPrivatePtr); static void NewPacket (AceCadPrivatePtr priv); static Bool AceCadGetPacket (AceCadPrivatePtr); static int AceCadPreInit(InputDriverPtr, InputInfoPtr , int); +static void AceCadUnInit(InputDriverPtr, InputInfoPtr , int); #ifdef HAVE_LINUX_INPUT_H static void USBReadInput (InputInfoPtr); static Bool USBQueryHardware (InputInfoPtr); |