From 96ef05a9d157c92cc2f5c1eb7afd7cb9e6ffa73d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 11 Nov 2016 10:14:03 +0000 Subject: [PATCH] fix a crash in arg handling on Windows we were not updating argc in vips.c after all calls to g_option_context_parse_strv() on Windows, leading to a crash in some cases see https://github.com/jcupitt/libvips/issues/553 --- ChangeLog | 3 +++ configure.ac | 6 +++--- tools/vips.c | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90d493d4..5cf8f631 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +11/11/16 started 8.4.4 +- fix crash in vips.exe arg parsing on Windows, thanks Yury + 18/10/16 started 8.4.3 - fix error detection in gif_close, thanks aaron42net - fix tiny threading memleak diff --git a/configure.ac b/configure.ac index 563294bb..c8192ddc 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [8.4.3], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [8.4.4], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [8]) m4_define([vips_minor_version], [4]) -m4_define([vips_micro_version], [3]) +m4_define([vips_micro_version], [4]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=48 -LIBRARY_REVISION=3 +LIBRARY_REVISION=4 LIBRARY_AGE=6 # patched into include/vips/version.h diff --git a/tools/vips.c b/tools/vips.c index caa35929..eff1ffcb 100644 --- a/tools/vips.c +++ b/tools/vips.c @@ -1041,12 +1041,18 @@ parse_options( GOptionContext *context, int *argc, char **argv ) vips_error_exit( NULL ); } + /* On Windows, argc will not have been updated by + * g_option_context_parse_strv(). + */ + for( *argc = 0; argv[*argc]; (*argc)++ ) + ; + /* Remove any "--" argument. If one of our arguments is a negative * number, the user will need to have added the "--" flag to stop * GOption parsing. But "--" is still passed down to us and we need to * ignore it. */ - for( i = 1; i < *argc - 1; i++ ) + for( i = 1; i < *argc; i++ ) if( strcmp( argv[i], "--" ) == 0 ) { for( j = i; j < *argc; j++ ) argv[j] = argv[j + 1];