apps/nshlib/nsh_console.c: Do not dereference NULL 'pstate'
@@ -448,6 +448,12 @@ FAR struct console_stdio_s *nsh_newconsole(void)
pstate->cn_vtbl.linebuffer = nsh_consolelinebuffer;
pstate->cn_vtbl.exit = nsh_consoleexit;
+#ifndef CONFIG_NSH_DISABLESCRIPT
+ /* Set the initial option flags */
+
+ pstate->cn_vtbl.np.np_flags = NSH_NP_SET_OPTIONS_INIT;
+#endif
+
#if CONFIG_NFILE_STREAMS > 0
pstate->cn_vtbl.redirect = nsh_consoleredirect;
pstate->cn_vtbl.undirect = nsh_consoleundirect;
@@ -480,11 +486,5 @@ FAR struct console_stdio_s *nsh_newconsole(void)
#endif
}
-#ifndef CONFIG_NSH_DISABLESCRIPT
- /* Set the initial option flags */
-
- pstate->cn_vtbl.np.np_flags = NSH_NP_SET_OPTIONS_INIT;
-#endif
-
return pstate;
}
