From: Bruno Haible Date: Tue, 14 Mar 2023 00:38:13 +0000 (+0100) Subject: lisp-format: Fix a crash in format string that contains "~@?" before "~V". X-Git-Tag: v0.22~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85d4cb991e6a8c111d0739c343bba22143c094d6;p=thirdparty%2Fgettext.git lisp-format: Fix a crash in format string that contains "~@?" before "~V". * gettext-tools/src/format-lisp.c (nocheck_params): Don't call add_req_type_constraint if position < 0. * gettext-tools/tests/xgettext-lisp-5: New file. * gettext-tools/tests/Makefile.am (TESTS): Add it. --- diff --git a/gettext-tools/src/format-lisp.c b/gettext-tools/src/format-lisp.c index 57e23210d..d89746b76 100644 --- a/gettext-tools/src/format-lisp.c +++ b/gettext-tools/src/format-lisp.c @@ -2426,7 +2426,8 @@ nocheck_params (struct format_arg_list **listp, if (params->type == PT_V) { int position = params->value; - add_req_type_constraint (listp, position, FAT_CHARACTER_INTEGER_NULL); + if (position >= 0) + add_req_type_constraint (listp, position, FAT_CHARACTER_INTEGER_NULL); } return true; diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 5349c7624..2edb31138 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -122,6 +122,7 @@ TESTS = gettext-1 gettext-2 \ xgettext-librep-1 xgettext-librep-2 xgettext-librep-3 \ xgettext-librep-stackovfl-1 xgettext-librep-stackovfl-2 \ xgettext-lisp-1 xgettext-lisp-2 xgettext-lisp-3 xgettext-lisp-4 \ + xgettext-lisp-5 \ xgettext-lisp-stackovfl-1 xgettext-lisp-stackovfl-2 \ xgettext-lua-1 xgettext-lua-2 xgettext-lua-3 \ xgettext-lua-stackovfl-1 xgettext-lua-stackovfl-2 \ diff --git a/gettext-tools/tests/xgettext-lisp-5 b/gettext-tools/tests/xgettext-lisp-5 new file mode 100755 index 000000000..0818128d4 --- /dev/null +++ b/gettext-tools/tests/xgettext-lisp-5 @@ -0,0 +1,24 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test Lisp support: lisp-format string with a ~V at an unknown position. + +cat < xg-ls-5.lisp +(gettext "~@?~v!") +EOF + +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location -d xg-ls-5.tmp xg-ls-5.lisp || Exit 1 +LC_ALL=C tr -d '\r' < xg-ls-5.tmp.po > xg-ls-5.po || Exit 1 + +cat < xg-ls-5.ok +#, lisp-format +msgid "~@?~v!" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-ls-5.ok xg-ls-5.po +result=$? + +exit $result