Skip to content

Commit 0d2448e

Browse files
committed
Fix UI transpiler segfaults by adding null pointer guards in transpileStmt
1 parent 88207c6 commit 0d2448e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/compiler/transpiler_ui.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static void transpileStmt(Stmt *stmt, FILE *html, FILE *js, int indent) {
163163

164164
switch (stmt->type) {
165165
case STMT_UI_STATE:
166+
if (!js) break;
166167
printIndent(js, indent);
167168
fprintf(js, "%s: ", stmt->as.ui_state.name);
168169
if (stmt->as.ui_state.initializer) {
@@ -174,6 +175,7 @@ static void transpileStmt(Stmt *stmt, FILE *html, FILE *js, int indent) {
174175
break;
175176

176177
case STMT_UI_ACTION:
178+
if (!js) break;
177179
printIndent(js, indent);
178180
fprintf(js, "%s() {\n", stmt->as.ui_action.name);
179181
// Transpile action body statements if they exist
@@ -189,6 +191,7 @@ static void transpileStmt(Stmt *stmt, FILE *html, FILE *js, int indent) {
189191
break;
190192

191193
case STMT_UI_COMPONENT: {
194+
if (!html) break;
192195
const char *htmlTag = mapTag(stmt->as.ui_component.tag);
193196
printIndent(html, indent);
194197
fprintf(html, "<%s", htmlTag);
@@ -237,6 +240,7 @@ static void transpileStmt(Stmt *stmt, FILE *html, FILE *js, int indent) {
237240
}
238241

239242
case STMT_UI_WINDOW: {
243+
if (!html) break;
240244
printIndent(html, indent);
241245
fprintf(html, "<div id=\"window-%s\" class=\"prox-window\">\n", stmt->as.ui_window.name);
242246
for (int i = 0; i < stmt->as.ui_window.body->count; i++) {

0 commit comments

Comments
 (0)