Address crashes on linput's use of printf.
On an empty line input, a C3 with UART console would panic while attempting to output the new Lua prompt. The backtrace shows a xQueueSemaphoreTake with uxItemSize==0 as the panic cause, deep inside the uart driver, invoked via vfs_uart and vfs_console layers, from printf. Similarly, the printf for outputting a backspace/erase sequence would also trigger a panic. This workaround (of not mixing fflush() with printf) is likely merely hiding a deeper issue, but it appears to be consistent. Plus, printf with no args and a user-supplied format string is a no-no and should be fixed anyway.
This commit is contained in:
parent
916a93fe2a
commit
70c7437cdc
|
@ -3,6 +3,7 @@
|
|||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static struct input_state {
|
||||
char *data;
|
||||
|
@ -59,7 +60,7 @@ size_t feed_lua_input(const char *buf, size_t n)
|
|||
/* backspace key */
|
||||
if (ch == DEL || ch == BS) {
|
||||
if (ins.line_pos > 0) {
|
||||
if(input_echo) printf(BS_OVER);
|
||||
if(input_echo) fwrite(BS_OVER, strlen(BS_OVER), 1, stdout);
|
||||
ins.line_pos--;
|
||||
}
|
||||
ins.data[ins.line_pos] = 0;
|
||||
|
@ -73,7 +74,7 @@ size_t feed_lua_input(const char *buf, size_t n)
|
|||
if (input_echo) putchar(LF);
|
||||
if (ins.line_pos == 0) {
|
||||
/* Get a empty line, then go to get a new line */
|
||||
printf(ins.prompt);
|
||||
fwrite(ins.prompt, strlen(ins.prompt), 1, stdout);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
ins.data[ins.line_pos++] = LF;
|
||||
|
|
Loading…
Reference in New Issue