|
Lines 52-57
public:
Link Here
|
| 52 |
// generation 0. |
52 |
// generation 0. |
| 53 |
ObjectStream(XRef *xref, int objStrNumA); |
53 |
ObjectStream(XRef *xref, int objStrNumA); |
| 54 |
|
54 |
|
|
|
55 |
GBool isOk() { return ok; } |
| 56 |
|
| 55 |
~ObjectStream(); |
57 |
~ObjectStream(); |
| 56 |
|
58 |
|
| 57 |
// Return the object number of this object stream. |
59 |
// Return the object number of this object stream. |
|
Lines 67-72
private:
Link Here
|
| 67 |
int nObjects; // number of objects in the stream |
69 |
int nObjects; // number of objects in the stream |
| 68 |
Object *objs; // the objects (length = nObjects) |
70 |
Object *objs; // the objects (length = nObjects) |
| 69 |
int *objNums; // the object numbers (length = nObjects) |
71 |
int *objNums; // the object numbers (length = nObjects) |
|
|
72 |
GBool ok; |
| 70 |
}; |
73 |
}; |
| 71 |
|
74 |
|
| 72 |
ObjectStream::ObjectStream(XRef *xref, int objStrNumA) { |
75 |
ObjectStream::ObjectStream(XRef *xref, int objStrNumA) { |
|
Lines 80-85
ObjectStream::ObjectStream(XRef *xref, i
Link Here
|
| 80 |
nObjects = 0; |
83 |
nObjects = 0; |
| 81 |
objs = NULL; |
84 |
objs = NULL; |
| 82 |
objNums = NULL; |
85 |
objNums = NULL; |
|
|
86 |
ok = gFalse; |
| 83 |
|
87 |
|
| 84 |
if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) { |
88 |
if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) { |
| 85 |
goto err1; |
89 |
goto err1; |
|
Lines 105-110
ObjectStream::ObjectStream(XRef *xref, i
Link Here
|
| 105 |
goto err1; |
109 |
goto err1; |
| 106 |
} |
110 |
} |
| 107 |
|
111 |
|
|
|
112 |
// this is an arbitrary limit to avoid integer overflow problems |
| 113 |
// in the 'new Object[nObjects]' call (Acrobat apparently limits |
| 114 |
// object streams to 100-200 objects) |
| 115 |
if (nObjects > 1000000) { |
| 116 |
error(-1, "Too many objects in an object stream"); |
| 117 |
goto err1; |
| 118 |
} |
| 108 |
objs = new Object[nObjects]; |
119 |
objs = new Object[nObjects]; |
| 109 |
objNums = (int *)gmallocn(nObjects, sizeof(int)); |
120 |
objNums = (int *)gmallocn(nObjects, sizeof(int)); |
| 110 |
offsets = (int *)gmallocn(nObjects, sizeof(int)); |
121 |
offsets = (int *)gmallocn(nObjects, sizeof(int)); |
|
Lines 161-170
ObjectStream::ObjectStream(XRef *xref, i
Link Here
|
| 161 |
} |
172 |
} |
| 162 |
|
173 |
|
| 163 |
gfree(offsets); |
174 |
gfree(offsets); |
|
|
175 |
ok = gTrue; |
| 164 |
|
176 |
|
| 165 |
err1: |
177 |
err1: |
| 166 |
objStr.free(); |
178 |
objStr.free(); |
| 167 |
return; |
|
|
| 168 |
} |
179 |
} |
| 169 |
|
180 |
|
| 170 |
ObjectStream::~ObjectStream() { |
181 |
ObjectStream::~ObjectStream() { |
|
Lines 837-842
Object *XRef::fetch(int num, int gen, Ob
Link Here
|
| 837 |
delete objStr; |
848 |
delete objStr; |
| 838 |
} |
849 |
} |
| 839 |
objStr = new ObjectStream(this, e->offset); |
850 |
objStr = new ObjectStream(this, e->offset); |
|
|
851 |
if (!objStr->isOk()) { |
| 852 |
delete objStr; |
| 853 |
objStr = NULL; |
| 854 |
goto err; |
| 855 |
} |
| 840 |
} |
856 |
} |
| 841 |
objStr->getObject(e->gen, num, obj); |
857 |
objStr->getObject(e->gen, num, obj); |
| 842 |
break; |
858 |
break; |