Permalink
Browse files

ts_close: fix segfault on close

  • Loading branch information...
1 parent f6c499a commit 39a2e8eaf87604d87e08d4229c13270290d7c9e0 @dougg3 dougg3 committed Mar 22, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/ts_close.c
View
@@ -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);

0 comments on commit 39a2e8e

Please sign in to comment.