Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ts_close: fix segfault on close

  • Loading branch information...
commit 39a2e8eaf87604d87e08d4229c13270290d7c9e0 1 parent f6c499a
Doug Brown dougg3 authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/ts_close.c
14 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);
Please sign in to comment.
Something went wrong with that request. Please try again.