changeset 1228:01efa0e5b554

file->handle should be cleared on close, otherwise it can lead to double free.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Tue, 10 Jul 2007 14:21:15 +0900
parents 7a081f2998d0
children c9ff58a0feab
files src/curl/curl.c src/lastfm/lastfm.c src/mms/mms.c src/stdio/stdio.c
diffstat 4 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/curl/curl.c	Mon Jul 09 08:09:21 2007 -0500
+++ b/src/curl/curl.c	Tue Jul 10 14:21:15 2007 +0900
@@ -722,6 +722,7 @@
         g_free(handle->url);
 
       g_free(handle);
+      file->handle = NULL;
     }
   return ret;
 }
--- a/src/lastfm/lastfm.c	Mon Jul 09 08:09:21 2007 -0500
+++ b/src/lastfm/lastfm.c	Tue Jul 10 14:21:15 2007 +0900
@@ -380,12 +380,14 @@
 
         if (file == NULL)
                 return -1;
-        LastFM *handle = file->handle;
-        ret = vfs_fclose(handle->proxy_fd);
-        if (!ret)
+        if (file->handle) {
+            LastFM *handle = file->handle;
+            ret = vfs_fclose(handle->proxy_fd);
+            if (!ret)
                 handle->proxy_fd = NULL;
-        g_free(handle);
-        handle=NULL;
+            g_free(handle);
+            file->handle = NULL;
+        }
         return ret;
 }
 
--- a/src/mms/mms.c	Mon Jul 09 08:09:21 2007 -0500
+++ b/src/mms/mms.c	Tue Jul 10 14:21:15 2007 +0900
@@ -86,6 +86,7 @@
 
         mms_close(handle->mms);
         g_free(handle);
+        file->handle = NULL;
     }
 
     return ret;
--- a/src/stdio/stdio.c	Mon Jul 09 08:09:21 2007 -0500
+++ b/src/stdio/stdio.c	Tue Jul 10 14:21:15 2007 +0900
@@ -111,6 +111,7 @@
 
         if (fclose(handle) != 0)
             ret = -1;
+        file->handle = NULL;
     }
 
     return ret;