OSDN Git Service

check return value of opendir in hb_close. hb_close was segfaulting when
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 11 Sep 2008 16:04:21 +0000 (16:04 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 11 Sep 2008 16:04:21 +0000 (16:04 +0000)
called a second time to close a second instance of libhb.

git-svn-id: svn://localhost/HandBrake/trunk@1688 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb.c

index cde5132..390e566 100644 (file)
@@ -1306,19 +1306,22 @@ static void thread_func( void * _h )
 
     /* Remove temp folder */
     dir = opendir( dirname );
-    while( ( entry = readdir( dir ) ) )
+    if (dir)
     {
-        char filename[1024];
-        if( entry->d_name[0] == '.' )
+        while( ( entry = readdir( dir ) ) )
         {
-            continue;
+            char filename[1024];
+            if( entry->d_name[0] == '.' )
+            {
+                continue;
+            }
+            memset( filename, 0, 1024 );
+            snprintf( filename, 1023, "%s/%s", dirname, entry->d_name );
+            unlink( filename );
         }
-        memset( filename, 0, 1024 );
-        snprintf( filename, 1023, "%s/%s", dirname, entry->d_name );
-        unlink( filename );
+        closedir( dir );
+        rmdir( dirname );
     }
-    closedir( dir );
-    rmdir( dirname );
 }
 
 /**