xgettext: In language JavaScript, avoid a crash.

This avoids a crash
"Assertion `phase2_pushback_length + j < SIZEOF (phase2_pushback)' failed.".

* gettext-tools/src/x-javascript.c (phase2_pushback): Increase size by 1.
* gettext-tools/tests/xgettext-javascript-12: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
This commit is contained in:
Bruno Haible 2023-03-13 00:21:50 +01:00
parent 0baf23d1db
commit ff78c835ad
3 changed files with 24 additions and 3 deletions

View File

@ -215,8 +215,8 @@ phase1_ungetc (int c)
static lexical_context_ty lexical_context;
/* Maximum used, length of "<![CDATA[" tag minus one. */
static int phase2_pushback[8];
/* Maximum used, length of "<![CDATA[" tag. */
static int phase2_pushback[9];
static int phase2_pushback_length;
/* Read the next Unicode UCS-4 character from the input file. */

View File

@ -114,7 +114,7 @@ TESTS = gettext-1 gettext-2 \
xgettext-javascript-1 xgettext-javascript-2 xgettext-javascript-3 \
xgettext-javascript-4 xgettext-javascript-5 xgettext-javascript-6 \
xgettext-javascript-7 xgettext-javascript-8 xgettext-javascript-9 \
xgettext-javascript-10 xgettext-javascript-11 \
xgettext-javascript-10 xgettext-javascript-11 xgettext-javascript-12 \
xgettext-javascript-stackovfl-1 xgettext-javascript-stackovfl-2 \
xgettext-javascript-stackovfl-3 xgettext-javascript-stackovfl-4 \
xgettext-javascript-stackovfl-5 xgettext-javascript-stackovfl-6 \

View File

@ -0,0 +1,21 @@
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
# Test JavaScript support: maximum needed for phase2_pushback.
printf '<![CDATA0' > xg-js-12a.js
printf '<![CDATA012345' > xg-js-12b.js
: ${XGETTEXT=xgettext}
LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location -d xg-js-12.tmp xg-js-12a.js 2>xg-js-12.err
result=$?
cat xg-js-12.err
test $result = 0 || Exit 1
: ${XGETTEXT=xgettext}
LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location -d xg-js-12.tmp xg-js-12b.js 2>xg-js-12.err
result=$?
cat xg-js-12.err
test $result = 0 || Exit 1
exit 0