瀏覽代碼

Check for NULL prompt in readline_into_buffer()

Previously, passing readline() or readline_into_buffer() a NULL 'prompt'
parameter would result in puts() printing garbage when
CONFIG_CMDLINE_EDITING was enabled.

Note that no board currently triggers this bug.  Enabling
CONFIG_CMDLINE_EDITING on some boards (eg bab7xx) would result in
the bug appearing.  This change is only intended to prevent someone
from running into this issue in the future.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Peter Tyser 15 年之前
父節點
當前提交
e491a71e57
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      common/main.c

+ 2 - 1
common/main.c

@@ -964,7 +964,8 @@ int readline_into_buffer (const char *const prompt, char * buffer)
 			initted = 1;
 		}
 
-		puts (prompt);
+		if (prompt)
+			puts (prompt);
 
 		rc = cread_line(prompt, p, &len);
 		return rc < 0 ? rc : len;