serial: sandbox: Fix buffer underflow in puts
Fix the buffer underflow that would occur if puts is called with length
of zero.
Fixes: efa51f2bd6
("serial: sandbox: Implement puts")
Cc: Sean Anderson <sean.anderson@seco.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Sean Anderson <sean.anderson@seco.com>
This commit is contained in:
parent
9121478ee6
commit
337b26e468
@ -114,7 +114,7 @@ static ssize_t sandbox_serial_puts(struct udevice *dev, const char *s,
|
||||
struct sandbox_serial_priv *priv = dev_get_priv(dev);
|
||||
ssize_t ret;
|
||||
|
||||
if (s[len - 1] == '\n')
|
||||
if (len && s[len - 1] == '\n')
|
||||
priv->start_of_line = true;
|
||||
|
||||
if (sandbox_serial_enabled) {
|
||||
|
Loading…
Reference in New Issue
Block a user