Skip to content
Permalink
Browse files

add vips_error_buffer_copy()

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

See #1423

Thanks @dineshkannaa
  • Loading branch information...
jcupitt committed Sep 12, 2019
1 parent d290c97 commit efdf33f3dea462388ed3423cd9282a794b648b8a
Showing with 24 additions and 0 deletions.
  1. +1 −0 ChangeLog
  2. +1 −0 libvips/include/vips/error.h
  3. +22 −0 libvips/iofuncs/error.c
@@ -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
@@ -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 );
@@ -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.
*

0 comments on commit efdf33f

Please sign in to comment.
You can’t perform that action at this time.