add vips_error_buffer_copy()

Add vips_error_buffer_copy() to fix a race in error buffer fetch.

See https://github.com/libvips/libvips/issues/1423

Thanks @dineshkannaa
This commit is contained in:
John Cupitt 2019-09-12 09:49:49 +01:00
parent d290c971ab
commit efdf33f3de
3 changed files with 24 additions and 0 deletions

View File

@ -15,6 +15,7 @@
- handle alpha in heifload / heifsave [meyermarcel]
- add @interpretation and @format to rawload
- nifti load/save uses double for all floating point metadata
- add vips_error_buffer_copy()
31/8/19 started 8.8.3
- revert sharpen restoring the input colourspace

View File

@ -36,6 +36,7 @@ extern "C" {
#endif /*__cplusplus*/
const char *vips_error_buffer( void );
char *vips_error_buffer_copy( void );
void vips_error_clear( void );
void vips_error_freeze( void );

View File

@ -14,6 +14,8 @@
* - gtkdoc comments
* 24/6/10
* - fmt to error_exit() may be NULL
* 12/9/19 [dineshkannaa]
* - add vips_error_buffer_copy()
*/
/*
@ -184,6 +186,26 @@ vips_error_buffer( void )
return( msg );
}
/**
* vips_error_buffer_copy:
*
* Return a copy of the vips error buffer, and clear it.
*
* Returns: a copy of the libvips error buffer
*/
char *
vips_error_buffer_copy( void )
{
char *msg;
g_mutex_lock( vips__global_lock );
msg = g_strdup( vips_buf_all( &vips_error_buf ) );
vips_error_clear();
g_mutex_unlock( vips__global_lock );
return( msg );
}
/* Some systems do not have va_copy() ... this might work (it does on MSVC),
* apparently.
*