Fix the buffer underflow that would occur if puts is called with length
of zero.
Fixes: efa51f2bd64 ("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>
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) {