[poppler] 3 commits - goo/GooString.cc poppler/Function.cc poppler/Function.h qt4/tests
Albert Astals Cid
aacid at kemper.freedesktop.org
Sun Nov 25 15:41:43 PST 2012
goo/GooString.cc | 5 +--
poppler/Function.cc | 63 ++++++++++++++++++++++++++++++++++--------
poppler/Function.h | 11 ++++---
qt4/tests/CMakeLists.txt | 1
qt4/tests/Makefile.am | 7 ++++
qt4/tests/check_goostring.cpp | 22 ++++++++++++++
6 files changed, 90 insertions(+), 19 deletions(-)
New commits:
commit 62c0dbbe9f1987c78eeb87f248d35e7fd73e968a
Author: Albert Astals Cid <aacid at kde.org>
Date: Mon Nov 26 00:40:57 2012 +0100
Check GooString::insert
Checks we don't break what we just fixed with Pino's patch
diff --git a/qt4/tests/CMakeLists.txt b/qt4/tests/CMakeLists.txt
index 9eaaa02..187870f 100644
--- a/qt4/tests/CMakeLists.txt
+++ b/qt4/tests/CMakeLists.txt
@@ -57,6 +57,7 @@ qt4_add_qtest(check_permissions check_permissions.cpp)
qt4_add_qtest(check_search check_search.cpp)
qt4_add_qtest(check_actualtext check_actualtext.cpp)
qt4_add_qtest(check_lexer check_lexer.cpp)
+qt4_add_qtest(check_goostring check_goostring.cpp)
if (NOT WIN32)
qt4_add_qtest(check_strings check_strings.cpp)
endif (NOT WIN32)
diff --git a/qt4/tests/Makefile.am b/qt4/tests/Makefile.am
index ed38d17..3dc6e13 100644
--- a/qt4/tests/Makefile.am
+++ b/qt4/tests/Makefile.am
@@ -78,7 +78,8 @@ TESTS = \
check_pagelayout \
check_search \
check_strings \
- check_lexer
+ check_lexer \
+ check_goostring
check_PROGRAMS = $(TESTS)
@@ -138,5 +139,9 @@ check_lexer_SOURCES = check_lexer.cpp
check_lexer.$(OBJEXT): check_lexer.moc
check_lexer_LDADD = $(LDADDS) $(POPPLER_QT4_TEST_LIBS)
+check_goostring_SOURCES = check_goostring.cpp
+check_goostring.$(OBJEXT): check_goostring.moc
+check_goostring_LDADD = $(LDADDS) $(POPPLER_QT4_TEST_LIBS)
+
endif
diff --git a/qt4/tests/check_goostring.cpp b/qt4/tests/check_goostring.cpp
new file mode 100644
index 0000000..41c28d3
--- /dev/null
+++ b/qt4/tests/check_goostring.cpp
@@ -0,0 +1,22 @@
+#include <QtTest/QtTest>
+
+#include "GooString.h"
+
+class TestGooString : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testInsert();
+};
+
+void TestGooString::testInsert()
+{
+ GooString goo;
+ goo.insert(0, ".");
+ goo.insert(0, "This is a very long long test string");
+ QCOMPARE(goo.getCString(), "This is a very long long test string.");
+}
+
+QTEST_MAIN(TestGooString)
+#include "check_goostring.moc"
+
commit 01e438ca47776075c8171bda090e7d859fd9f620
Author: Adam Reichold <adamreichold at myopera.com>
Date: Mon Nov 26 00:39:05 2012 +0100
Don't use memcpy to copy classes
diff --git a/poppler/Function.cc b/poppler/Function.cc
index d26aed8..1dece2d 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -18,6 +18,7 @@
// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
// Copyright (C) 2011 Andrea Canciani <ranma42 at gmail.com>
// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2012 Adam Reichold <adamreichold at myopera.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -106,6 +107,16 @@ Function *Function::parse(Object *funcObj, std::set<int> *usedParents) {
return func;
}
+Function::Function(const Function *func) {
+ m = func->m;
+ n = func->n;
+
+ memcpy(domain, func->domain, funcMaxInputs * 2 * sizeof(double));
+ memcpy(range, func->range, funcMaxOutputs * 2 * sizeof(double));
+
+ hasRange = func->hasRange;
+}
+
GBool Function::init(Dict *dict) {
Object obj1, obj2;
int i;
@@ -419,13 +430,28 @@ SampledFunction::~SampledFunction() {
}
}
-SampledFunction::SampledFunction(SampledFunction *func) {
- memcpy(this, func, sizeof(SampledFunction));
+SampledFunction::SampledFunction(const SampledFunction *func) : Function(func) {
+ memcpy(sampleSize, func->sampleSize, funcMaxInputs * sizeof(int));
+
+ memcpy(encode, func->encode, funcMaxInputs * 2 * sizeof(double));
+ memcpy(decode, func->decode, funcMaxOutputs * 2 * sizeof(double));
+
+ memcpy(inputMul, func->inputMul, funcMaxInputs * sizeof(double));
+
+ nSamples = func->nSamples;
+
idxOffset = (int *)gmallocn(1 << m, sizeof(int));
memcpy(idxOffset, func->idxOffset, (1 << m) * (int)sizeof(int));
+
samples = (double *)gmallocn(nSamples, sizeof(double));
memcpy(samples, func->samples, nSamples * sizeof(double));
+
sBuf = (double *)gmallocn(1 << m, sizeof(double));
+
+ memcpy(cacheIn, func->cacheIn, funcMaxInputs * sizeof(double));
+ memcpy(cacheOut, func->cacheOut, funcMaxOutputs * sizeof(double));
+
+ ok = func->ok;
}
void SampledFunction::transform(double *in, double *out) {
@@ -616,8 +642,13 @@ ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) {
ExponentialFunction::~ExponentialFunction() {
}
-ExponentialFunction::ExponentialFunction(ExponentialFunction *func) {
- memcpy(this, func, sizeof(ExponentialFunction));
+ExponentialFunction::ExponentialFunction(const ExponentialFunction *func) : Function(func) {
+ memcpy(c0, func->c0, funcMaxOutputs * sizeof(double));
+ memcpy(c1, func->c1, funcMaxOutputs * sizeof(double));
+
+ e = func->e;
+ isLinear = func->isLinear;
+ ok = func->ok;
}
void ExponentialFunction::transform(double *in, double *out) {
@@ -761,21 +792,24 @@ StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict, std::set<int>
obj1.free();
}
-StitchingFunction::StitchingFunction(StitchingFunction *func) {
- int i;
+StitchingFunction::StitchingFunction(const StitchingFunction *func) : Function(func) {
+ k = func->k;
- memcpy(this, func, sizeof(StitchingFunction));
funcs = (Function **)gmallocn(k, sizeof(Function *));
- for (i = 0; i < k; ++i) {
+ for (int i = 0; i < k; ++i) {
funcs[i] = func->funcs[i]->copy();
}
+
bounds = (double *)gmallocn(k + 1, sizeof(double));
memcpy(bounds, func->bounds, (k + 1) * sizeof(double));
+
encode = (double *)gmallocn(2 * k, sizeof(double));
memcpy(encode, func->encode, 2 * k * sizeof(double));
+
scale = (double *)gmallocn(k, sizeof(double));
memcpy(scale, func->scale, k * sizeof(double));
- ok = gTrue;
+
+ ok = func->ok;
}
StitchingFunction::~StitchingFunction() {
@@ -1184,11 +1218,18 @@ PostScriptFunction::PostScriptFunction(Object *funcObj, Dict *dict) {
return;
}
-PostScriptFunction::PostScriptFunction(PostScriptFunction *func) {
- memcpy(this, func, sizeof(PostScriptFunction));
+PostScriptFunction::PostScriptFunction(const PostScriptFunction *func) : Function(func) {
+ codeSize = func->codeSize;
+
code = (PSObject *)gmallocn(codeSize, sizeof(PSObject));
memcpy(code, func->code, codeSize * sizeof(PSObject));
+
codeString = func->codeString->copy();
+
+ memcpy(cacheIn, func->cacheIn, funcMaxInputs * sizeof(double));
+ memcpy(cacheOut, func->cacheOut, funcMaxOutputs * sizeof(double));
+
+ ok = func->ok;
}
PostScriptFunction::~PostScriptFunction() {
diff --git a/poppler/Function.h b/poppler/Function.h
index 25df133..90e2a76 100644
--- a/poppler/Function.h
+++ b/poppler/Function.h
@@ -17,6 +17,7 @@
// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
// Copyright (C) 2011 Andrea Canciani <ranma42 at gmail.com>
// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2012 Adam Reichold <adamreichold at myopera.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -90,6 +91,8 @@ public:
protected:
static Function *parse(Object *funcObj, std::set<int> *usedParents);
+ Function(const Function *func);
+
int m, n; // size of input and output tuples
double // min and max values for function domain
domain[funcMaxInputs][2];
@@ -140,7 +143,7 @@ public:
private:
- SampledFunction(SampledFunction *func);
+ SampledFunction(const SampledFunction *func);
int // number of samples for each domain element
sampleSize[funcMaxInputs];
@@ -179,7 +182,7 @@ public:
private:
- ExponentialFunction(ExponentialFunction *func);
+ ExponentialFunction(const ExponentialFunction *func);
double c0[funcMaxOutputs];
double c1[funcMaxOutputs];
@@ -210,7 +213,7 @@ public:
private:
- StitchingFunction(StitchingFunction *func);
+ StitchingFunction(const StitchingFunction *func);
int k;
Function **funcs;
@@ -238,7 +241,7 @@ public:
private:
- PostScriptFunction(PostScriptFunction *func);
+ PostScriptFunction(const PostScriptFunction *func);
GBool parseCode(Stream *str, int *codePtr);
GooString *getToken(Stream *str);
void resizeCode(int newSize);
commit 7ba15d11e56175601104d125d5e4a47619c224bf
Author: Pino Toscano <pino at kde.org>
Date: Mon Nov 26 00:29:35 2012 +0100
fix GooString::insert()
Hi,
as reported in a Debian bug [1], it seems GooString::insert could lead
to using uninitialized memory.
The case is a simple:
GooString goo;
goo.insert(0, ".");
goo.insert(0, "This is a very long long test string");
i.e. basically first insert a single character at position 0, and then a
string longer than STR_STATIC_SIZE always at position 0.
[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693817
diff --git a/goo/GooString.cc b/goo/GooString.cc
index 451a70e..e52380e 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -22,6 +22,7 @@
// Copyright (C) 2011 Kenji Uno <ku at digitaldolphins.jp>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
// Copyright (C) 2012 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2012 Pino Toscano <pino at kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -769,14 +770,12 @@ GooString *GooString::insert(int i, GooString *str) {
}
GooString *GooString::insert(int i, const char *str, int lengthA) {
- int j;
int prevLen = length;
if (CALC_STRING_LEN == lengthA)
lengthA = strlen(str);
resize(length + lengthA);
- for (j = prevLen; j >= i; --j)
- s[j+lengthA] = s[j];
+ memmove(s+i+lengthA, s+i, prevLen);
memcpy(s+i, str, lengthA);
return this;
}
More information about the poppler
mailing list