shithub: libmujs

Download patch

ref: f5b3c703e18725e380b83427004632e744f85a6f
parent: 910acc807c3c057e1c0726160808f3a9f37b40ec
author: Tor Andersson <[email protected]>
date: Tue May 17 11:57:00 EDT 2022

Issue #161: Cope with empty programs in mujs-pp.

--- a/jsdump.c
+++ b/jsdump.c
@@ -682,11 +682,13 @@
 void jsP_dumpsyntax(js_State *J, js_Ast *prog, int dominify)
 {
 	minify = dominify;
-	if (prog->type == AST_LIST)
-		pstmlist(-1, prog);
-	else {
-		pstm(0, prog);
-		nl();
+	if (prog) {
+		if (prog->type == AST_LIST)
+			pstmlist(-1, prog);
+		else {
+			pstm(0, prog);
+			nl();
+		}
 	}
 	if (minify > 1)
 		putchar('\n');
@@ -768,11 +770,13 @@
 void jsP_dumplist(js_State *J, js_Ast *prog)
 {
 	minify = 0;
-	if (prog->type == AST_LIST)
-		sblock(0, prog);
-	else
-		snode(0, prog);
-	nl();
+	if (prog) {
+		if (prog->type == AST_LIST)
+			sblock(0, prog);
+		else
+			snode(0, prog);
+		nl();
+	}
 }
 
 /* Compiled code */