summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2008-09-11 16:04:21 +0000
committerjstebbins <[email protected]>2008-09-11 16:04:21 +0000
commita3a83842d26ad83b8e7a7b9dd876e8ce6af9dcb9 (patch)
tree437b72c9c76b3538a231753207eba4a35bdb0349 /libhb
parent3053f495fe52dcdd38db2b104d2ea392dfc6761e (diff)
check return value of opendir in hb_close. hb_close was segfaulting when
called a second time to close a second instance of libhb. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1688 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/hb.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index cde51322c..390e566d2 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -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 );
}
/**