From 273effeec2469a97998c7d2c0147007e6bb04bf2 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 21 Feb 2017 16:07:20 +0100 Subject: The 'count' array in pdf_annot_set_ink_list takes number of points. Not number of coordinates. --- source/tools/murun.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/tools/murun.c b/source/tools/murun.c index bff3cc61..90b7cd17 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -4059,13 +4059,13 @@ static void ffi_PDFAnnotation_setInkList(js_State *J) nv = 0; for (i = 0; i < n; ++i) { js_getindex(J, 1, i); - nv += js_getlength(J, -1); + nv += js_getlength(J, -1) / 2; js_pop(J, 1); } fz_try(ctx) { counts = fz_malloc(ctx, n * sizeof(int)); - points = fz_malloc(ctx, nv * sizeof(float)); + points = fz_malloc(ctx, nv * 2 * sizeof(float)); } fz_catch(ctx) { fz_free(ctx, counts); fz_free(ctx, points); @@ -4079,11 +4079,10 @@ static void ffi_PDFAnnotation_setInkList(js_State *J) } for (i = v = 0; i < n; ++i) { js_getindex(J, 1, i); - counts[i] = js_getlength(J, -1); - for (k = 0; k < counts[i]; ++k) { + counts[i] = js_getlength(J, -1) / 2; + for (k = 0; k < counts[i] * 2; ++k) { js_getindex(J, -1, k); - if (v < nv) - points[v++] = js_tonumber(J, -1); + points[v++] = js_tonumber(J, -1); js_pop(J, 1); } js_pop(J, 1); -- cgit v1.2.3