--- a/content/handlers/image/rsvg.c
+++ b/content/handlers/image/rsvg.c
@@ -138,16 +138,20 @@ static bool rsvg_process_data(struct content *c, const char *data,
 static inline void rsvg_argb_to_abgr(uint8_t *pixels, 
 		int width, int height, size_t rowstride)
 {
-	uint8_t *p = pixels;
+	unsigned char *p = (void *)pixels;
 
 	for (int y = 0; y < height; y++) {
 		for (int x = 0; x < width; x++) {
-			/* Swap R and B */
-			const uint8_t r = p[x+3];
-
-			p[x+3] = p[x];
-
-			p[x] = r;
+			union {
+				uint8_t ch[4];
+				uint32_t col;
+			} *px = (void *)&p[x*4], npx;
+
+			npx.ch[0] = px->col >> 16;
+			npx.ch[1] = px->col >> 8;
+			npx.ch[2] = px->col;
+			npx.ch[3] = px->col >> 24;
+			*px = npx;
 		}
 
 		p += rowstride;
