From 0b3ab3a934cf8c129986d5dd450bcc10f44db5b0 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 11 Sep 2022 14:26:53 +0100 Subject: [PATCH] fix null string in buffer print Some libvips header fields can be NULL, for example filename, and we need to avoid null pointer deref on print. See https://github.com/libvips/libvips/issues/3043 --- libvips/iofuncs/buf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libvips/iofuncs/buf.c b/libvips/iofuncs/buf.c index 3061981a..19be0a91 100644 --- a/libvips/iofuncs/buf.c +++ b/libvips/iofuncs/buf.c @@ -262,6 +262,8 @@ vips_buf_appendns( VipsBuf *buf, const char *str, int sz ) if( buf->full ) return( FALSE ); + if( !str ) + return( TRUE ); /* Amount we want to copy. */ @@ -528,7 +530,7 @@ vips_buf_appendgv( VipsBuf *buf, GValue *value ) * handled by boxed, see below. */ str = g_value_get_string( value ); - result = vips_buf_appends( buf, str ); + result = vips_buf_appends( buf, str ); handled = TRUE; } break;