From 3f40cbc53efd5ec6b9feac2d624577d6380e6831 Mon Sep 17 00:00:00 2001 From: daniel-starke Date: Fri, 21 Apr 2017 18:41:59 +0200 Subject: [PATCH] Fixed reverse shape list implementation --- src/nanosvg.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/nanosvg.h b/src/nanosvg.h index c49de48..b805534 100644 --- a/src/nanosvg.h +++ b/src/nanosvg.h @@ -2787,7 +2787,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) { NSVGparser* p; NSVGimage* ret = 0; - NSVGshape* cur, *tmp; + NSVGshape* cur, *prev, *tmp; p = nsvg__createParser(); if (p == NULL) { @@ -2799,13 +2799,14 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) // Reverse the list of shapes to match SVG order cur = p->image->shapes; - while (cur && cur->next != NULL) { - tmp = cur->next; - cur->next = cur->next->next; - tmp->next = p->image->shapes; - p->image->shapes = tmp; + prev = NULL; + while (cur != NULL) { + tmp = cur; cur = cur->next; + tmp->next = prev; + prev = tmp; } + if (prev != NULL) p->image->shapes = prev; // Scale to viewBox nsvg__scaleToViewbox(p, units);