Skip to content

Commit

Permalink
ts_close: fix segfault on close
Browse files Browse the repository at this point in the history
  • Loading branch information
dougg3 committed Mar 22, 2012
1 parent f6c499a commit 39a2e8e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ts_close.c
Expand Up @@ -22,15 +22,19 @@ int ts_close(struct tsdev *ts)
{
void *handle;
int ret;
struct tslib_module_info *info, *prev;

for(info = ts->list, prev = info;
info != NULL;
info = prev->next, prev = info) {
struct tslib_module_info *info, *next;

info = ts->list;
while(info) {
/* Save the "next" pointer now because info will be freed */
next = info->next;

handle = info->handle;
info->ops->fini(info);
if (handle)
dlclose(handle);

info = next;
}

ret = close(ts->fd);
Expand Down

0 comments on commit 39a2e8e

Please sign in to comment.