Permalink
Browse files

Merge pull request #7 from dougg3/master

ts_close segfault fix
  • Loading branch information...
2 parents b8ef1eb + 39a2e8e commit 158ee49b32f83cb7b02d5315f41c2e4cff38942d @kergoth committed Mar 21, 2013
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 158ee49

Please sign in to comment.