From f5188ee3f6fd27b5ad4156fb9a5575b96325576f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 17 Mar 2013 15:19:37 +0000 Subject: [PATCH 1/3] better arg without value handling this was segv-ing: vips tiffsave v26722.tif v26722.pyr.tif --tile -tile-width 256 (only one hypen before tile-width) thanks Ruven --- ChangeLog | 1 + libvips/iofuncs/object.c | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4188cfb2..e8f04651 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 6/2/13 started 7.32.2 - removed some left-over debugging code from configure.ac +- better handling of args without values, thanks Ruven 6/2/13 started 7.32.1 - fix --without-lcms, thanks speckins diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index b91bcde6..b5e9b672 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -1462,6 +1462,29 @@ vips_enum_error( VipsObjectClass *class, GType otype, const char *value ) g_type_name( otype ), value, vips_buf_all( &buf ) ); } +static void +vips_object_no_value( VipsObject *object, const char *name ) +{ + VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); + + GParamSpec *pspec; + VipsArgumentClass *argument_class; + VipsArgumentInstance *argument_instance; + + if( vips_object_get_argument( object, name, + &pspec, &argument_class, &argument_instance ) ) + g_assert( 0 ); + + if( strcmp( name, g_param_spec_get_name( pspec ) ) == 0 ) + vips_error( class->nickname, + _( "no value supplied for argument '%s'" ), name ); + else + vips_error( class->nickname, + _( "no value supplied for argument '%s' ('%s')" ), + name, + g_param_spec_get_name( pspec ) ); +} + /* Set a named arg from a string. */ int @@ -1498,6 +1521,11 @@ vips_object_set_argument_from_string( VipsObject *object, flags = vips_operation_get_flags( VIPS_OPERATION( object ) ); + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + /* Read the filename. vips_foreign_load_options() * handles embedded options. */ @@ -1525,6 +1553,11 @@ vips_object_set_argument_from_string( VipsObject *object, (oclass = g_type_class_ref( otype )) ) { VipsObject *new_object; + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + if( !(new_object = vips_object_new_from_string( oclass, value )) ) return( -1 ); @@ -1560,6 +1593,11 @@ vips_object_set_argument_from_string( VipsObject *object, else if( G_IS_PARAM_SPEC_INT( pspec ) ) { int i; + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + if( sscanf( value, "%d", &i ) != 1 ) { vips_error( class->nickname, _( "'%s' is not an integer" ), value ); @@ -1574,6 +1612,11 @@ vips_object_set_argument_from_string( VipsObject *object, */ long long l; + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + if( sscanf( value, "%Ld", &l ) != 1 ) { vips_error( class->nickname, _( "'%s' is not an integer" ), value ); @@ -1586,6 +1629,11 @@ vips_object_set_argument_from_string( VipsObject *object, else if( G_IS_PARAM_SPEC_DOUBLE( pspec ) ) { double d; + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + if( sscanf( value, "%lg", &d ) != 1 ) { vips_error( class->nickname, _( "'%s' is not a double" ), value ); @@ -1598,6 +1646,11 @@ vips_object_set_argument_from_string( VipsObject *object, else if( G_IS_PARAM_SPEC_ENUM( pspec ) ) { GEnumValue *enum_value; + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + if( !(enum_value = g_enum_get_value_by_name( g_type_class_ref( otype ), value )) ) { if( !(enum_value = g_enum_get_value_by_nick( @@ -1615,6 +1668,11 @@ vips_object_set_argument_from_string( VipsObject *object, */ int i; + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + if( sscanf( value, "%d", &i ) != 1 ) { vips_error( class->nickname, _( "'%s' is not an integer" ), value ); @@ -1625,6 +1683,11 @@ vips_object_set_argument_from_string( VipsObject *object, g_value_set_flags( &gvalue, i ); } else { + if( !value ) { + vips_object_no_value( object, name ); + return( -1 ); + } + g_value_init( &gvalue, G_TYPE_STRING ); g_value_set_string( &gvalue, value ); } From 162d71de08ca141dff46106d36b884d917e4c747 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 17 Mar 2013 16:08:24 -0400 Subject: [PATCH 2/3] Update Free Software Foundation address in one more file --- libvips/iofuncs/base64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libvips/iofuncs/base64.c b/libvips/iofuncs/base64.c index ce89e51c..6c2e1c48 100644 --- a/libvips/iofuncs/base64.c +++ b/libvips/iofuncs/base64.c @@ -15,7 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA * * \section{Base-64 Routines} * From 4ebe588da64ac01e2c1d09f325631b6b200f27e7 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Mar 2013 09:12:06 +0000 Subject: [PATCH 3/3] fix compile without jpeg im_jpeg2vips.c failed to compile if jpeglib.h was missing, thanks Alessandro --- ChangeLog | 1 + libvips/deprecated/im_jpeg2vips.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ede40b01..7084d5bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - removed some left-over debugging code from configure.ac - better handling of args without values, thanks Ruven - better error messages from vips.c +- im_jpeg2vips.c builds without jpeglib.h, thanks Alessandro 6/2/13 started 7.32.1 - fix --without-lcms, thanks speckins diff --git a/libvips/deprecated/im_jpeg2vips.c b/libvips/deprecated/im_jpeg2vips.c index 269366b0..8ba81b3b 100644 --- a/libvips/deprecated/im_jpeg2vips.c +++ b/libvips/deprecated/im_jpeg2vips.c @@ -44,13 +44,15 @@ #include #include +#include #include -#include +#ifdef HAVE_JPEG #include #include #include "../foreign/jpeg.h" +#endif /*HAVE_JPEG*/ static int jpeg2vips( const char *name, IMAGE *out, gboolean header_only ) @@ -116,7 +118,8 @@ jpeg2vips( const char *name, IMAGE *out, gboolean header_only ) header_only, shrink, fail_on_warn ) ) return( -1 ); #else - vips_error( "im_jpeg2vips", _( "no JPEG support in your libvips" ) ); + vips_error( "im_jpeg2vips", + "%s", _( "no JPEG support in your libvips" ) ); return( -1 ); #endif /*HAVE_JPEG*/