SDL_image: nanosvgrast.h: do not call qsort() when r->edges == NULL

From 721992a0e66f01e8143108136e5e2b6c5b5e695a Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 7 May 2022 14:56:50 +0300
Subject: [PATCH] nanosvgrast.h: do not call qsort() when r->edges == NULL

From mainstream PR/210, patch by Christopher Chavez
---
 nanosvgrast.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/nanosvgrast.h b/nanosvgrast.h
index 41bf318..9ec3e55 100644
--- a/nanosvgrast.h
+++ b/nanosvgrast.h
@@ -1413,7 +1413,8 @@ NSVG_EXPORT void nsvgRasterize(NSVGrasterizer* r,
 			}
 
 			// Rasterize edges
-			qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+			if (r->edges != NULL)
+				qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
 
 			// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
 			nsvg__initPaint(&cache, &shape->fill, shape->opacity);
@@ -1439,7 +1440,8 @@ NSVG_EXPORT void nsvgRasterize(NSVGrasterizer* r,
 			}
 
 			// Rasterize edges
-			qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+			if (r->edges != NULL)
+				qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
 
 			// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
 			nsvg__initPaint(&cache, &shape->stroke, shape->opacity);