diff --git a/src/m_misc.c b/src/m_misc.c
index 232ccb47747073c7fa712078db039b56fa3bd18a..0445136fe06d5facd7c064d2f05c5ae5ab3af3cc 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1032,7 +1032,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
 static inline moviemode_t M_StartMovieAPNG(const char *pathname)
 {
 #ifdef USE_APNG
-	UINT8 *palette;
+	UINT8 *palette = NULL;
 	const char *freename = NULL;
 	boolean ret = false;
 
@@ -1048,8 +1048,13 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname)
 		return MM_OFF;
 	}
 
-	if (rendermode == render_soft) M_CreateScreenShotPalette();
-	ret = M_SetupaPNG(va(pandf,pathname,freename), (palette = screenshot_palette));
+	if (rendermode == render_soft)
+	{
+		M_CreateScreenShotPalette();
+		palette = screenshot_palette;
+	}
+
+	ret = M_SetupaPNG(va(pandf,pathname,freename), palette);
 
 	if (!ret)
 	{