block metadata changes on shared images
If images are shared (ref count > 1), block changes to the set of metadata items on the image. These can cause crashes in highly threaded programs. See https://github.com/lovell/sharp/issues/1986
This commit is contained in:
parent
1a2a4a41f1
commit
20cee5d041
@ -1020,6 +1020,13 @@ vips_image_set( VipsImage *image, const char *name, GValue *value )
|
||||
g_assert( name );
|
||||
g_assert( value );
|
||||
|
||||
/* If this image is shared, block metadata changes.
|
||||
*/
|
||||
if( G_OBJECT( image )->ref_count > 1 ) {
|
||||
g_info( "can't set metadata \"%s\" on shared image", name );
|
||||
return;
|
||||
}
|
||||
|
||||
meta_init( image );
|
||||
(void) meta_new( image, name, value );
|
||||
|
||||
@ -1213,6 +1220,13 @@ vips_image_get_typeof( const VipsImage *image, const char *name )
|
||||
gboolean
|
||||
vips_image_remove( VipsImage *image, const char *name )
|
||||
{
|
||||
/* If this image is shared, block metadata changes.
|
||||
*/
|
||||
if( G_OBJECT( image )->ref_count > 1 ) {
|
||||
g_info( "can't remove metadata \"%s\" on shared image", name );
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
if( image->meta &&
|
||||
g_hash_table_remove( image->meta, name ) )
|
||||
return( TRUE );
|
||||
|
Loading…
x
Reference in New Issue
Block a user