configure.ac | 2 ++ fofi/FoFiTrueType.cc | 8 ++++---- goo/GooString.cc | 19 +++++++++++++++++++ poppler/Stream.cc | 2 ++ poppler/Stream.h | 4 ++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 3f43c0e..0c3f444 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,8 @@ AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_ AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system])) AC_CHECK_FUNC(rand_r, AC_DEFINE(HAVE_RAND_R, 1, [Defines if rand_r is available on your system])) +AC_FUNC_ALLOCA + dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) AC_CHECK_FUNC(gethostbyname) if test $ac_cv_func_gethostbyname = no; then diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index 6ab8f9b..6848bd5 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -1222,15 +1222,15 @@ void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, dumpString(file + tables[j].offset, tables[j].len, outputFunc, outputStream); } else if (needVerticalMetrics && i == t42VheaTable) { - if (unlikely(length >= (int)sizeof(vheaTab))) { + if (unlikely(length > (int)sizeof(vheaTab))) { error(errSyntaxWarning, -1, "length bigger than vheaTab size"); - length = sizeof(vheaTab) - 1; + length = sizeof(vheaTab); } dumpString(vheaTab, length, outputFunc, outputStream); } else if (needVerticalMetrics && i == t42VmtxTable) { - if (unlikely(length >= vmtxTabLength)) { + if (unlikely(length > vmtxTabLength)) { error(errSyntaxWarning, -1, "length bigger than vmtxTab size"); - length = vmtxTabLength - 1; + length = vmtxTabLength; } dumpString(vmtxTab, length, outputFunc, outputStream); } diff --git a/goo/GooString.cc b/goo/GooString.cc index 8591d95..7ff2a3c 100644 --- a/goo/GooString.cc +++ b/goo/GooString.cc @@ -47,6 +47,10 @@ static const int MAXIMUM_DOUBLE_PREC = 16; +#if HAVE_ALLOCA_H +# include +#endif + //------------------------------------------------------------------------ union GooStringFormatArg { @@ -323,7 +327,11 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { argsLen = 0; argsSize = 8; +#if HAVE_ALLOCA_H + args = (GooStringFormatArg *)alloca(argsSize * sizeof(GooStringFormatArg)); +#else args = (GooStringFormatArg *)gmallocn(argsSize, sizeof(GooStringFormatArg)); +#endif p0 = fmt; while (*p0) { @@ -392,8 +400,16 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { if (idx == argsLen) { if (argsLen == argsSize) { argsSize *= 2; +#if HAVE_ALLOCA_H + { + GooStringFormatArg *new_args = (GooStringFormatArg *)alloca(argsSize * sizeof(GooStringFormatArg)); + memcpy(new_args, args, argsLen); + args = new_args; + } +#else args = (GooStringFormatArg *)greallocn(args, argsSize, sizeof(GooStringFormatArg)); +#endif } switch (ft) { case fmtIntDecimal: @@ -632,7 +648,10 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { } } +#if HAVE_ALLOCA_H +#else gfree(args); +#endif return this; } diff --git a/poppler/Stream.cc b/poppler/Stream.cc index d2dd761..5a51276 100644 --- a/poppler/Stream.cc +++ b/poppler/Stream.cc @@ -4580,12 +4580,14 @@ void FlateStream::reset() { eof = gFalse; } +#if 0 int FlateStream::getChar() { if (pred) { return pred->getChar(); } return doGetRawChar(); } +#endif int FlateStream::getChars(int nChars, Guchar *buffer) { if (pred) { diff --git a/poppler/Stream.h b/poppler/Stream.h index 00b2925..ec88955 100644 --- a/poppler/Stream.h +++ b/poppler/Stream.h @@ -979,7 +979,11 @@ public: virtual ~FlateStream(); virtual StreamKind getKind() { return strFlate; } virtual void reset(); +#ifdef ENABLE_ZLIB virtual int getChar(); +#else + virtual inline int getChar() { return pred ? pred->getChar(): doGetRawChar(); } +#endif virtual int lookChar(); virtual int getRawChar(); virtual void getRawChars(int nChars, int *buffer);