Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
io-glib: fix for invalid access
Browse files Browse the repository at this point in the history
  • Loading branch information
waht committed Aug 18, 2018
1 parent 9744189 commit d9f855e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/bindings/io/glib/io_glib.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ static int ioGlibBindingFdDispatch (GSource * source, GSourceFunc callback, void
return G_SOURCE_CONTINUE;
}

/**
* Cleanup after file descriptor has been detached
* @param source glib source
*/
static void ioGlibBindingFdCleanup (GSource * source)
{
FdSource * fdSource = (FdSource *) source;
elektraFree (fdSource->bindingData->fdFuncs);
elektraFree (fdSource->bindingData);
}

/**
* Calls the associated callback.
* Called by glib whenever a timer has elapsed.
Expand Down Expand Up @@ -282,7 +293,7 @@ static int ioGlibBindingAddFd (ElektraIoInterface * binding, ElektraIoFdOperatio
funcs->prepare = ioGlibBindingFdPrepare;
funcs->check = ioGlibBindingFdCheck;
funcs->dispatch = ioGlibBindingFdDispatch;
funcs->finalize = NULL;
funcs->finalize = ioGlibBindingFdCleanup;
bindingData->fdFuncs = funcs;
FdSource * fdSource = (FdSource *) g_source_new (funcs, sizeof *fdSource);
GSource * gSource = &fdSource->gSource;
Expand Down Expand Up @@ -320,8 +331,6 @@ static int ioGlibBindingRemoveFd (ElektraIoFdOperation * fdOp)
}
g_source_destroy (gSource);
g_source_unref (gSource);
elektraFree (bindingData->fdFuncs);
elektraFree (bindingData);

return 1;
}
Expand Down

0 comments on commit d9f855e

Please sign in to comment.