mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-25 22:55:20 +02:00
eeshow/gfx/pdftoc.c (write_trailer): walking pointer is a bad idea if we realloc
This commit is contained in:
parent
82f578d4b4
commit
cdb68f70a2
@ -248,9 +248,9 @@ static void write_trailer(struct pdftoc *ctx)
|
|||||||
{
|
{
|
||||||
unsigned n = ctx->top + 1;
|
unsigned n = ctx->top + 1;
|
||||||
const struct object *obj = ctx->objs;
|
const struct object *obj = ctx->objs;
|
||||||
const struct object *end = ctx->objs + ctx->top + 1;
|
|
||||||
const struct title *t;
|
const struct title *t;
|
||||||
unsigned outline, tail;
|
unsigned outline, tail;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Outline root */
|
/* Outline root */
|
||||||
|
|
||||||
@ -267,10 +267,12 @@ static void write_trailer(struct pdftoc *ctx)
|
|||||||
/* Outline items */
|
/* Outline items */
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
|
i = 0;
|
||||||
for (t = ctx->titles; t; t = t->next) {
|
for (t = ctx->titles; t; t = t->next) {
|
||||||
while (!obj->is_page) {
|
assert(i <= ctx->top);
|
||||||
assert(obj != end);
|
while (!ctx->objs[i].is_page) {
|
||||||
obj++;
|
i++;
|
||||||
|
assert(i <= ctx->top);
|
||||||
}
|
}
|
||||||
add_object(ctx, n, 0, ctx->pos + tail);
|
add_object(ctx, n, 0, ctx->pos + tail);
|
||||||
tail += fprintf(ctx->file,
|
tail += fprintf(ctx->file,
|
||||||
@ -285,11 +287,11 @@ static void write_trailer(struct pdftoc *ctx)
|
|||||||
tail += fprintf(ctx->file,
|
tail += fprintf(ctx->file,
|
||||||
" /Next %u 0 R\n", n + 1);
|
" /Next %u 0 R\n", n + 1);
|
||||||
tail += fprintf(ctx->file,
|
tail += fprintf(ctx->file,
|
||||||
" /Dest [%u %u R /Fit]\n"
|
" /Dest [%d %u R /Fit]\n"
|
||||||
">>\nendobj\n",
|
">>\nendobj\n",
|
||||||
(unsigned) (obj - ctx->objs), obj->gen);
|
i, ctx->objs[i].gen);
|
||||||
n++;
|
n++;
|
||||||
obj++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* xref table */
|
/* xref table */
|
||||||
|
Loading…
Reference in New Issue
Block a user