From 5fce021c17ccaa6bb0765b0dc4b10633647d528d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 20 Nov 2013 21:38:31 +0000 Subject: [PATCH 1/8] fix typo in find_mosaic.c thanks dcb314 https://github.com/jcupitt/libvips/issues/81 --- tools/find_mosaic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/find_mosaic.c b/tools/find_mosaic.c index 4e1f856c..530482bd 100644 --- a/tools/find_mosaic.c +++ b/tools/find_mosaic.c @@ -260,7 +260,7 @@ double scale1, angle1, dx1, dy1; } if( ( inp[curr_im]->Xsize < xoff ) || ( inp[curr_im+1]->Xsize < xoff ) || - ( inp[curr_im]->Ysize < yoff ) || ( inp[curr_im]->Ysize < yoff) ){ + ( inp[curr_im]->Ysize < yoff ) || ( inp[curr_im+1]->Ysize < yoff) ){ ++curr_disp_x; hxdisp[curr_disp_x] = 0; hydisp[curr_disp_x] = 0; From 54dcea8c3d15ae30ee986c0485e7598c3b169eec Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 21 Nov 2013 17:43:28 +0000 Subject: [PATCH 2/8] fix some clang warnings --- libvips/colour/icc_transform.c | 2 +- libvips/deprecated/im_analyze2vips.c | 3 ++- libvips/deprecated/im_exr2vips.c | 3 ++- libvips/deprecated/im_openslide2vips.c | 3 ++- libvips/deprecated/im_ppm2vips.c | 3 ++- libvips/deprecated/im_tiff2vips.c | 3 ++- libvips/foreign/ppmload.c | 2 +- libvips/foreign/webp2vips.c | 2 +- libvips/include/vips/foreign.h | 7 +++++-- libvips/include/vips/image.h | 2 +- libvips/iofuncs/enumtypes.c | 2 +- libvips/iofuncs/image.c | 4 ++-- 12 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libvips/colour/icc_transform.c b/libvips/colour/icc_transform.c index 8c14cfab..cc677105 100644 --- a/libvips/colour/icc_transform.c +++ b/libvips/colour/icc_transform.c @@ -635,7 +635,7 @@ vips_icc_export_build( VipsObject *object ) if( !vips_object_argument_isset( object, "pcs" ) && code->in && code->in->Type == VIPS_INTERPRETATION_XYZ ) - icc->pcs = VIPS_INTERPRETATION_XYZ; + icc->pcs = VIPS_PCS_XYZ; if( icc->pcs == VIPS_PCS_LAB ) { #ifdef HAVE_LCMS2 diff --git a/libvips/deprecated/im_analyze2vips.c b/libvips/deprecated/im_analyze2vips.c index 8b5646b7..f4d892c9 100644 --- a/libvips/deprecated/im_analyze2vips.c +++ b/libvips/deprecated/im_analyze2vips.c @@ -48,7 +48,8 @@ static VipsFormatFlags analyze_flags( const char *filename ) { - return( vips_foreign_flags( "analyzeload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "analyzeload", filename ) ); } static int diff --git a/libvips/deprecated/im_exr2vips.c b/libvips/deprecated/im_exr2vips.c index c5f1b081..7e478f16 100644 --- a/libvips/deprecated/im_exr2vips.c +++ b/libvips/deprecated/im_exr2vips.c @@ -74,7 +74,8 @@ exr_flags( const char *name ) im_filename_split( name, filename, mode ); - return( vips_foreign_flags( "openexrload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "openexrload", filename ) ); } static int diff --git a/libvips/deprecated/im_openslide2vips.c b/libvips/deprecated/im_openslide2vips.c index 88acd1ff..a1c27d58 100644 --- a/libvips/deprecated/im_openslide2vips.c +++ b/libvips/deprecated/im_openslide2vips.c @@ -110,7 +110,8 @@ openslide_flags( const char *name ) im_filename_split( name, filename, mode ); - return( vips_foreign_flags( "openslideload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "openslideload", filename ) ); } static int diff --git a/libvips/deprecated/im_ppm2vips.c b/libvips/deprecated/im_ppm2vips.c index 52ec532b..1108223c 100644 --- a/libvips/deprecated/im_ppm2vips.c +++ b/libvips/deprecated/im_ppm2vips.c @@ -63,7 +63,8 @@ isppm( const char *filename ) static VipsFormatFlags ppm_flags( const char *filename ) { - return( vips_foreign_flags( "ppmload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "ppmload", filename ) ); } static const char *ppm_suffs[] = { ".ppm", ".pgm", ".pbm", ".pfm", NULL }; diff --git a/libvips/deprecated/im_tiff2vips.c b/libvips/deprecated/im_tiff2vips.c index 1bb1c90d..eecfd5fb 100644 --- a/libvips/deprecated/im_tiff2vips.c +++ b/libvips/deprecated/im_tiff2vips.c @@ -132,7 +132,8 @@ tiff_flags( const char *name ) im_filename_split( name, filename, mode ); - return( vips_foreign_flags( "tiffload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "tiffload", filename ) ); } static int diff --git a/libvips/foreign/ppmload.c b/libvips/foreign/ppmload.c index eb1a727c..ef610f24 100644 --- a/libvips/foreign/ppmload.c +++ b/libvips/foreign/ppmload.c @@ -67,7 +67,7 @@ G_DEFINE_TYPE( VipsForeignLoadPpm, vips_foreign_load_ppm, static VipsForeignFlags vips_foreign_load_ppm_get_flags_filename( const char *filename ) { - return( vips__ppm_flags( filename ) ); + return( (VipsForeignFlags) vips__ppm_flags( filename ) ); } static VipsForeignFlags diff --git a/libvips/foreign/webp2vips.c b/libvips/foreign/webp2vips.c index 031ebad5..3f765d83 100644 --- a/libvips/foreign/webp2vips.c +++ b/libvips/foreign/webp2vips.c @@ -186,7 +186,7 @@ read_image( Read *read, VipsImage *out ) { VipsImage **t = (VipsImage **) vips_object_local_array( VIPS_OBJECT( out ), 3 ); - guint64 length; + gint64 length; void *data; int fd; webp_decoder decoder; diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index 736cb3af..a2ab314f 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -86,12 +86,15 @@ void *vips_foreign_map( const char *base, VipsSListMap2Fn fn, void *a, void *b ); /* Image file load properties. + * + * Keep in sync with the deprecated VipsFormatFlags, we need to be able to + * cast between them. */ typedef enum /*< flags >*/ { VIPS_FOREIGN_NONE = 0, /* No flags set */ VIPS_FOREIGN_PARTIAL = 1, /* Lazy read OK (eg. tiled tiff) */ - VIPS_FOREIGN_SEQUENTIAL = 2, /* Top-to-bottom lazy read OK */ - VIPS_FOREIGN_BIGENDIAN = 4, /* Most-significant byte first */ + VIPS_FOREIGN_BIGENDIAN = 2, /* Most-significant byte first */ + VIPS_FOREIGN_SEQUENTIAL = 4, /* Top-to-bottom lazy read OK */ VIPS_FOREIGN_ALL = 7 /* All flags set */ } VipsForeignFlags; diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index 5ba8689b..00878f2f 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -235,7 +235,7 @@ typedef struct _VipsImage { * file start. Usually VIPS_SIZEOF_HEADER, but can be something else * for binary file read. * - * gint64 so that we can guarantee to work even on systems with + * guint64 so that we can guarantee to work even on systems with * strange ideas about large files. */ guint64 sizeof_header; diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 273a4f90..3802017b 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -14,8 +14,8 @@ vips_foreign_flags_get_type( void ) static const GFlagsValue values[] = { {VIPS_FOREIGN_NONE, "VIPS_FOREIGN_NONE", "none"}, {VIPS_FOREIGN_PARTIAL, "VIPS_FOREIGN_PARTIAL", "partial"}, - {VIPS_FOREIGN_SEQUENTIAL, "VIPS_FOREIGN_SEQUENTIAL", "sequential"}, {VIPS_FOREIGN_BIGENDIAN, "VIPS_FOREIGN_BIGENDIAN", "bigendian"}, + {VIPS_FOREIGN_SEQUENTIAL, "VIPS_FOREIGN_SEQUENTIAL", "sequential"}, {VIPS_FOREIGN_ALL, "VIPS_FOREIGN_ALL", "all"}, {0, NULL, NULL} }; diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 22ac7927..75f555ff 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -879,9 +879,9 @@ vips_image_build( VipsObject *object ) break; case 'a': - /* Check parameters. + /* Ban crazy numbers. */ - if( image->sizeof_header < 0 ) { + if( image->sizeof_header > 1000000 ) { vips_error( "VipsImage", "%s", _( "bad parameters" ) ); return( -1 ); } From 64b5b9e514ec32347285501cd70bdb67b31a2e56 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Nov 2013 09:19:35 +0000 Subject: [PATCH 3/8] add SEQ operation hint to conv conv operations can run sequentially over images --- libvips/convolution/convolution.c | 3 +++ libvips/convolution/correlation.c | 3 +++ libvips/convolution/gaussblur.c | 3 +++ libvips/convolution/sharpen.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/libvips/convolution/convolution.c b/libvips/convolution/convolution.c index 270e7be7..e05dfcdc 100644 --- a/libvips/convolution/convolution.c +++ b/libvips/convolution/convolution.c @@ -104,6 +104,7 @@ vips_convolution_class_init( VipsConvolutionClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class ); + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class ); gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; @@ -112,6 +113,8 @@ vips_convolution_class_init( VipsConvolutionClass *class ) vobject_class->description = _( "convolution operations" ); vobject_class->build = vips_convolution_build; + operation_class->flags = VIPS_OPERATION_SEQUENTIAL; + /* Inputs set by subclassess. */ diff --git a/libvips/convolution/correlation.c b/libvips/convolution/correlation.c index e1a3facf..1831b790 100644 --- a/libvips/convolution/correlation.c +++ b/libvips/convolution/correlation.c @@ -131,6 +131,7 @@ vips_correlation_class_init( VipsCorrelationClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); VipsObjectClass *object_class = (VipsObjectClass *) class; + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class ); gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; @@ -139,6 +140,8 @@ vips_correlation_class_init( VipsCorrelationClass *class ) object_class->description = _( "correlation operation" ); object_class->build = vips_correlation_build; + operation_class->flags = VIPS_OPERATION_SEQUENTIAL; + VIPS_ARG_IMAGE( class, "in", 0, _( "Input" ), _( "Input image argument" ), diff --git a/libvips/convolution/gaussblur.c b/libvips/convolution/gaussblur.c index a344b534..b3290a56 100644 --- a/libvips/convolution/gaussblur.c +++ b/libvips/convolution/gaussblur.c @@ -102,6 +102,7 @@ vips_gaussblur_class_init( VipsGaussblurClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); VipsObjectClass *object_class = (VipsObjectClass *) class; + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class ); gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; @@ -110,6 +111,8 @@ vips_gaussblur_class_init( VipsGaussblurClass *class ) object_class->description = _( "Unsharp masking for print" ); object_class->build = vips_gaussblur_build; + operation_class->flags = VIPS_OPERATION_SEQUENTIAL; + VIPS_ARG_IMAGE( class, "in", 1, _( "Input" ), _( "Input image" ), diff --git a/libvips/convolution/sharpen.c b/libvips/convolution/sharpen.c index 46258f00..b264d6ae 100644 --- a/libvips/convolution/sharpen.c +++ b/libvips/convolution/sharpen.c @@ -295,6 +295,7 @@ vips_sharpen_class_init( VipsSharpenClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); VipsObjectClass *object_class = (VipsObjectClass *) class; + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class ); gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; @@ -303,6 +304,8 @@ vips_sharpen_class_init( VipsSharpenClass *class ) object_class->description = _( "Unsharp masking for print" ); object_class->build = vips_sharpen_build; + operation_class->flags = VIPS_OPERATION_SEQUENTIAL; + VIPS_ARG_IMAGE( class, "in", 1, _( "Input" ), _( "Input image" ), From 36f2f630d7110ca12e086453106d03222d11ed3d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Nov 2013 10:12:54 +0000 Subject: [PATCH 4/8] add clang notes --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 654c0e21..d0b92e7f 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,31 @@ Leak check: --leak-check=yes \ vips ... > vips-vg.log 2>&1 +Clang build: + + $ CC=clang CXX=clang++ ./configure --prefix=/home/john/vips + +Clang dynamic analysis: + + $ CC=clang CXX=clang++ LD=clang \ + CCFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + CXXFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + LDFLAGS=-fsanitize=address \ + ./configure --prefix=/home/john/vips --disable-introspection + + $ CC=clang CXX=clang++ LD=clang \ + CCFLAGS="-O1 -fsanitize=thread -fPIC -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + CXXFLAGS="-O1 -fsanitize=thread -fPIC -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + LDFLAGS="-fsanitize=thread -pie" \ + ./configure --prefix=/home/john/vips --disable-introspection + +Clang static analysis: + + $ configure as you please + $ scan-build -o scan make ... + + + # Dependencies libvips has to have gettext, glib-2.x and libxml-2.0. The build system needs From 2f602eedd6efb5db85a77eede193f0f47418e537 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Nov 2013 11:27:29 +0000 Subject: [PATCH 5/8] clang static analyze notes --- README.md | 12 +++++------- tools/find_mosaic.c | 26 +++++++++++++++----------- tools/mergeup.c | 28 +++++++++++++++------------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d0b92e7f..23b1b752 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,11 @@ Clang build: $ CC=clang CXX=clang++ ./configure --prefix=/home/john/vips +Clang static analysis: + + $ CC=... scan-build ./configure ... + $ scan-build -o scan -v make + Clang dynamic analysis: $ CC=clang CXX=clang++ LD=clang \ @@ -68,13 +73,6 @@ Clang dynamic analysis: LDFLAGS="-fsanitize=thread -pie" \ ./configure --prefix=/home/john/vips --disable-introspection -Clang static analysis: - - $ configure as you please - $ scan-build -o scan make ... - - - # Dependencies libvips has to have gettext, glib-2.x and libxml-2.0. The build system needs diff --git a/tools/find_mosaic.c b/tools/find_mosaic.c index 530482bd..1581e5b9 100644 --- a/tools/find_mosaic.c +++ b/tools/find_mosaic.c @@ -132,11 +132,13 @@ char *name; /* Find the x position of a file name (extract n from .nxm.v). */ static int -find_x( name ) -char *name; -{ int n; +find_x( char *name ) +{ + int n; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -166,17 +168,21 @@ char *name; return( -1 ); } + free( out ); + return( n ); } /* Find the y position of a file name (extract m from .nxm.v). */ static int -find_y( name ) -char *name; -{ int m; +find_y( char *name ) +{ + int m; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -207,12 +213,10 @@ char *name; } free( out ); + return( m ); } - - - static int mosaic_analysis(int width, int height,IMAGE **inp, IMAGE *out, int xoff, int yoff, int *vxdisp, int *vydisp,int *hxdisp, int *hydisp) { diff --git a/tools/mergeup.c b/tools/mergeup.c index d1b11de4..c87ba186 100644 --- a/tools/mergeup.c +++ b/tools/mergeup.c @@ -258,11 +258,13 @@ char *name; /* Find the x position of a file name (extract n from .nxm.v). */ static int -find_x( name ) -char *name; -{ int n; +find_x( char *name ) +{ + int n; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -292,17 +294,21 @@ char *name; return( -1 ); } + free( out ); + return( n ); } /* Find the y position of a file name (extract m from .nxm.v). */ static int -find_y( name ) -char *name; -{ int m; +find_y( char *name ) +{ + int m; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -333,14 +339,10 @@ char *name; } free( out ); + return( m ); } - - - - - /* Join two frames left-right. Have to open them and find their sizes. */ static int From 5b7b3cb591ffc2114ac143147843e1325ce45159 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Nov 2013 14:34:13 +0000 Subject: [PATCH 6/8] small fixes for clang static analyzer a few small things clang static analyzer found --- .gitignore | 1 + README.md | 3 ++- libvips/colour/LCh2Lab.c | 11 +++++++---- libvips/colour/Lab2LCh.c | 8 +++++--- libvips/conversion/cast.c | 2 +- libvips/conversion/rot45.c | 1 - libvips/foreign/csv.c | 4 ++-- libvips/foreign/fits.c | 1 - libvips/foreign/matlab.c | 1 - libvips/foreign/tiff2vips.c | 5 ++++- libvips/foreign/vips2tiff.c | 2 +- libvips/histogram/hist_local.c | 3 ++- libvips/inplace/flood.c | 19 +++++++------------ libvips/iofuncs/operation.c | 3 +++ 14 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 03ef54ad..8cf92bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +scan po/*.pot test-driver vips-*.tar.gz diff --git a/README.md b/README.md index 23b1b752..9f9939fe 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,9 @@ Clang build: Clang static analysis: - $ CC=... scan-build ./configure ... + $ scan-build ./configure --disable-introspection $ scan-build -o scan -v make + $ scan-view scan/2013-11-22-2 Clang dynamic analysis: diff --git a/libvips/colour/LCh2Lab.c b/libvips/colour/LCh2Lab.c index 7e646fd9..fc932667 100644 --- a/libvips/colour/LCh2Lab.c +++ b/libvips/colour/LCh2Lab.c @@ -62,11 +62,13 @@ G_DEFINE_TYPE( VipsLCh2Lab, vips_LCh2Lab, VIPS_TYPE_COLOUR_SPACE ); static void vips_LCh2Lab_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) { - float *p = (float *) in[0]; - float *q = (float *) out; - + float *p; + float *q; int x; + p = (float *) in[0]; + q = (float *) out; + for( x = 0; x < width; x++ ) { float L = p[0]; float C = p[1]; @@ -81,6 +83,7 @@ vips_LCh2Lab_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) q[0] = L; q[1] = a; q[2] = b; + q += 3; } } @@ -103,7 +106,7 @@ vips_col_Ch2ab( float C, float h, float *a, float *b ) in[1] = C; in[2] = h; - x = in; + x = &in[0]; vips_LCh2Lab_line( NULL, (VipsPel *) out, (VipsPel **) &x, 1 ); *a = out[1]; *b = out[2]; diff --git a/libvips/colour/Lab2LCh.c b/libvips/colour/Lab2LCh.c index 74228147..1c844052 100644 --- a/libvips/colour/Lab2LCh.c +++ b/libvips/colour/Lab2LCh.c @@ -98,11 +98,13 @@ vips_col_ab2Ch( float a, float b, float *C, float *h ) static void vips_Lab2LCh_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) { - float *p = (float *) in[0]; - float *q = (float *) out; - + float *p; + float *q; int x; + p = (float *) in[0]; + q = (float *) out; + for( x = 0; x < width; x++ ) { float L = p[0]; float a = p[1]; diff --git a/libvips/conversion/cast.c b/libvips/conversion/cast.c index be048d0c..9ff69072 100644 --- a/libvips/conversion/cast.c +++ b/libvips/conversion/cast.c @@ -172,7 +172,7 @@ vips_cast_start( VipsImage *out, void *a, void *b ) seq->underflow = 0; if( !seq->ir ) { - vips_cast_stop( seq, NULL, NULL ); + vips_cast_stop( seq, a, b ); return( NULL ); } diff --git a/libvips/conversion/rot45.c b/libvips/conversion/rot45.c index b6cfe2c4..283a4ec5 100644 --- a/libvips/conversion/rot45.c +++ b/libvips/conversion/rot45.c @@ -236,7 +236,6 @@ vips_rot45_build( VipsObject *object ) case VIPS_ANGLE45_45: vips_rot45_rot45( t[0], from ); - from = t[0]; break; default: diff --git a/libvips/foreign/csv.c b/libvips/foreign/csv.c index 75a85c6f..dfee788b 100644 --- a/libvips/foreign/csv.c +++ b/libvips/foreign/csv.c @@ -183,7 +183,7 @@ read_double( FILE *fp, const char whitemap[256], const char sepmap[256], if( ch == '"' ) { (void) fgetc( fp ); (void) skip_to_quote( fp ); - ch = fgetc( fp ); + (void) fgetc( fp ); } else if( !sepmap[ch] && fscanf( fp, "%lf", out ) != 1 ) { @@ -196,7 +196,7 @@ read_double( FILE *fp, const char whitemap[256], const char sepmap[256], /* Step over the bad data to the next separator. */ - ch = skip_to_sep( fp, sepmap ); + (void) skip_to_sep( fp, sepmap ); } /* Don't need to check result, we have read a field successfully. diff --git a/libvips/foreign/fits.c b/libvips/foreign/fits.c index ac0e4a9c..4a0a56e7 100644 --- a/libvips/foreign/fits.c +++ b/libvips/foreign/fits.c @@ -225,7 +225,6 @@ vips_fits_get_header( VipsFits *fits, VipsImage *out ) VIPS_DEBUG_MSG( "%d) %lld\n", i, fits->naxes[i] ); #endif /*VIPS_DEBUG*/ - width = 1; height = 1; bands = 1; switch( fits->naxis ) { diff --git a/libvips/foreign/matlab.c b/libvips/foreign/matlab.c index 36e497a0..ff0e9198 100644 --- a/libvips/foreign/matlab.c +++ b/libvips/foreign/matlab.c @@ -157,7 +157,6 @@ mat2vips_get_header( matvar_t *var, VipsImage *im ) VipsInterpretation interpretation; int i; - width = 1; height = 1; bands = 1; switch( var->rank ) { diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index bd139538..04dfa92e 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -1424,8 +1424,11 @@ read_stripwise( ReadTiff *rtiff, VipsImage *out ) /* rows_per_strip can be 2 ** 32 - 1, meaning the whole image. Clip * this down to ysize to avoid confusing vips. + * + * And it musn't be zero. */ - rtiff->rows_per_strip = VIPS_MIN( rtiff->rows_per_strip, t[0]->Ysize ); + rtiff->rows_per_strip = + VIPS_CLIP( 1, rtiff->rows_per_strip, t[0]->Ysize ); #ifdef DEBUG printf( "read_stripwise: rows_per_strip = %u\n", diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 0b0f2e80..73081cda 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1190,7 +1190,7 @@ write_tif_stripwise( TiffWrite *tw ) static void delete_files( TiffWrite *tw ) { - PyramidLayer *layer = tw->layer; + PyramidLayer *layer; if( tw->bname ) { #ifndef DEBUG diff --git a/libvips/histogram/hist_local.c b/libvips/histogram/hist_local.c index 41365738..c9ee1b06 100644 --- a/libvips/histogram/hist_local.c +++ b/libvips/histogram/hist_local.c @@ -93,7 +93,8 @@ vips_hist_local_stop( void *vseq, void *a, void *b ) VipsImage *in = (VipsImage *) a; VIPS_UNREF( seq->ir ); - if( seq->hist ) { + if( seq->hist && + in ) { int i; for( i = 0; i < in->Bands; i++ ) diff --git a/libvips/inplace/flood.c b/libvips/inplace/flood.c index 2f84a0a6..30d3a896 100644 --- a/libvips/inplace/flood.c +++ b/libvips/inplace/flood.c @@ -127,10 +127,9 @@ typedef struct { static Buffer * buffer_build( void ) { - Buffer *buf = IM_NEW( NULL, Buffer ); + Buffer *buf; - if( !buf ) - return( NULL ); + buf = g_new( Buffer, 1 ); buf->next = NULL; buf->n = 0; @@ -146,7 +145,7 @@ buffer_free( Buffer *buf ) Buffer *p; p = buf->next; - im_free( buf ); + g_free( buf ); buf = p; } } @@ -175,8 +174,7 @@ buffer_add( Buffer *buf, Flood *flood, int x1, int x2, int y, int dir ) if( buf->n == PBUFSIZE ) { Buffer *new; - if( !(new = buffer_build()) ) - return( NULL ); + new = buffer_build(); new->next = buf; buf = new; } @@ -382,13 +380,10 @@ flood_new( IMAGE *image, IMAGE *test, int x, int y, VipsPel *ink, Rect *dout ) flood->top = y; flood->right = x; flood->bottom = y; + flood->in = buffer_build(); + flood->out = buffer_build(); - flood->in = NULL; - flood->out = NULL; - - if( !(flood->edge = (VipsPel *) im_malloc( NULL, flood->tsize )) || - !(flood->in = buffer_build()) || - !(flood->out = buffer_build()) ) { + if( !(flood->edge = (VipsPel *) im_malloc( NULL, flood->tsize )) ) { flood_free( flood ); return( NULL ); } diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 6deb4db0..ade8ed0f 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -555,6 +555,9 @@ vips_call_required_optional( VipsOperation **operation, va_end( a ); va_end( b ); + if( result ) + return( -1 ); + /* Build from cache. */ if( vips_cache_operation_buildp( operation ) ) From 3b5eea59037918201fbac0e39d247b1dffedc7c6 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Nov 2013 14:50:40 +0000 Subject: [PATCH 7/8] sync --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f9939fe..61832401 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Clang dynamic analysis: $ CC=clang CXX=clang++ LD=clang \ CCFLAGS="-O1 -fsanitize=thread -fPIC -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ CXXFLAGS="-O1 -fsanitize=thread -fPIC -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ - LDFLAGS="-fsanitize=thread -pie" \ + LDFLAGS="-fsanitize=thread -fPIC -pie" \ ./configure --prefix=/home/john/vips --disable-introspection # Dependencies From 022f2ab1c36c794d9aabcc4e1f8aa5fdcd84d1b2 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 24 Nov 2013 11:10:42 +0000 Subject: [PATCH 8/8] sync --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61832401..51bc7f62 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,14 @@ Clang static analysis: Clang dynamic analysis: $ CC=clang CXX=clang++ LD=clang \ - CCFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + CFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ CXXFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ LDFLAGS=-fsanitize=address \ ./configure --prefix=/home/john/vips --disable-introspection $ CC=clang CXX=clang++ LD=clang \ - CCFLAGS="-O1 -fsanitize=thread -fPIC -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ - CXXFLAGS="-O1 -fsanitize=thread -fPIC -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + CFLAGS="-g -O1 -fsanitize=thread -fPIC -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ + CXXFLAGS="-g -O1 -fsanitize=thread -fPIC -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls" \ LDFLAGS="-fsanitize=thread -fPIC -pie" \ ./configure --prefix=/home/john/vips --disable-introspection