safer string equality in cache

it could segv if operations had strings which had been set to NULL
This commit is contained in:
John Cupitt 2012-07-17 10:10:34 +01:00
parent 467a78f32b
commit 4171f2673d
1 changed files with 9 additions and 3 deletions

View File

@ -265,9 +265,15 @@ vips_value_equal( GParamSpec *pspec, GValue *v1, GValue *v2 )
if( generic == G_TYPE_PARAM_DOUBLE )
return( g_value_get_double( v1 ) ==
g_value_get_double( v2 ) );
if( generic == G_TYPE_PARAM_STRING )
return( strcmp( g_value_get_string( v1 ),
g_value_get_string( v2 ) ) == 0 );
if( generic == G_TYPE_PARAM_STRING ) {
const char *s1 = g_value_get_string( v1 );
const char *s2 = g_value_get_string( v2 );
if( s1 == s2 )
return( TRUE );
else
return( s1 && s2 && strcmp( s1, s2 ) == 0 );
}
if( generic == G_TYPE_PARAM_BOXED )
return( g_value_get_boxed( v1 ) ==
g_value_get_boxed( v2 ) );