fix silly segv

If you called vips_object_map() before any vips objects had been
created, you got a segv.
This commit is contained in:
John Cupitt 2011-04-18 14:35:55 +01:00
parent f628b3c018
commit 1a42e75f80
1 changed files with 8 additions and 3 deletions

View File

@ -1238,11 +1238,16 @@ vips_object_map( VipsSListMap2Fn fn, void *a, void *b )
args.a = a;
args.b = b;
args.result = NULL;
g_mutex_lock( vips__object_all_lock );
if( vips__object_all )
/* We must test vips__object_all before we lock because the lock is
* only created when the first object is created.
*/
if( vips__object_all ) {
g_mutex_lock( vips__object_all_lock );
g_hash_table_foreach( vips__object_all,
(GHFunc) vips_object_map_sub, &args );
g_mutex_unlock( vips__object_all_lock );
g_mutex_unlock( vips__object_all_lock );
}
return( args.result );
}