[PATCH xf86-video-nested v4 06/11] Fix several memory leaks detected by valgrind.
Laércio de Sousa
laerciosousa at sme-mogidascruzes.sp.gov.br
Fri Nov 13 10:28:06 PST 2015
Signed-off-by: Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
---
src/driver.c | 7 +++++++
src/nested_input.c | 23 +++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/driver.c b/src/driver.c
index af70127..8aa53b2 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -259,6 +259,7 @@ NestedProbe(DriverPtr drv, int flags) {
}
}
+ free(devSections);
return foundScreen;
}
@@ -578,6 +579,11 @@ NestedAddMode(ScrnInfoPtr pScrn, int width, int height) {
// to force the initialization to wait until the input core is initialized.
static CARD32
NestedMouseTimer(OsTimerPtr timer, CARD32 time, pointer arg) {
+ if (timer) {
+ TimerFree(timer);
+ timer = NULL;
+ }
+
NestedInputLoadDriver(arg);
return 0;
}
@@ -711,6 +717,7 @@ NestedCloseScreen(CLOSE_SCREEN_ARGS_DECL) {
NestedClientCloseScreen(PCLIENTDATA(pScrn));
pScreen->CloseScreen = PNESTED(pScrn)->CloseScreen;
+
return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
}
diff --git a/src/nested_input.c b/src/nested_input.c
index 0d584c8..39f696f 100644
--- a/src/nested_input.c
+++ b/src/nested_input.c
@@ -189,6 +189,7 @@ _nested_input_init_keyboard(DeviceIntPtr device) {
}
static int
_nested_input_init_buttons(DeviceIntPtr device) {
+ int ret = Success;
InputInfoPtr pInfo = device->public.devicePrivate;
CARD8 *map;
Atom buttonLabels[NUM_MOUSE_BUTTONS] = {0};
@@ -201,12 +202,11 @@ _nested_input_init_buttons(DeviceIntPtr device) {
if (!InitButtonClassDeviceStruct(device, NUM_MOUSE_BUTTONS, buttonLabels, map)) {
xf86Msg(X_ERROR, "%s: Failed to register buttons.\n", pInfo->name);
-
- free(map);
- return BadAlloc;
+ ret = BadAlloc;
}
- return Success;
+ free(map);
+ return ret;
}
static int
@@ -233,6 +233,11 @@ nested_input_on(OsTimerPtr timer, CARD32 time, pointer arg) {
DeviceIntPtr device = arg;
InputInfoPtr pInfo = device->public.devicePrivate;
NestedInputDevicePtr pNestedInput = pInfo->private;
+
+ if (timer) {
+ TimerFree(timer);
+ timer = NULL;
+ }
if(device->public.on)
{
@@ -293,6 +298,12 @@ NestedInputControl(DeviceIntPtr device, int what) {
static CARD32
nested_input_ready(OsTimerPtr timer, CARD32 time, pointer arg) {
NestedClientPrivatePtr clientData = arg;
+
+ if (timer) {
+ TimerFree(timer);
+ timer = NULL;
+ }
+
NestedClientCheckEvents(clientData);
return 0;
}
@@ -344,8 +355,8 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) {
// Create input options for our invocation to NewInputDeviceRequest.
InputOption* options = NULL;
- options = input_option_new(options, strdup("identifier"), strdup("nestedinput"));
- options = input_option_new(options, strdup("driver"), strdup("nestedinput"));
+ options = input_option_new(options, "Identifier", "Nested virtual generic input device");
+ options = input_option_new(options, "Driver", "nestedinput");
// Invoke NewInputDeviceRequest to call the PreInit function of
// the driver.
--
2.1.4
More information about the xorg-devel
mailing list