Skip to content

Commit

Permalink
Fix buf_append_utf16le() error handling harder
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jul 31, 2014
1 parent 39c7877 commit 5cfe6f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions http.c
Expand Up @@ -205,14 +205,16 @@ int buf_append_utf16le(struct oc_text_buf *buf, const char *utf8)
nr_extra = 3;
min = 0x10000;
} else {
buf->error = -EINVAL;
if (buf)
buf->error = -EINVAL;
return -EINVAL;
}

while (nr_extra--) {
c = *(utf8++);
if ((c & 0xc0) != 0x80) {
buf->error = -EINVAL;
if (buf)
buf->error = -EINVAL;
return -EINVAL;
}
utfchar <<= 6;
Expand Down Expand Up @@ -241,7 +243,7 @@ int buf_append_utf16le(struct oc_text_buf *buf, const char *utf8)

/* Ensure UTF16 is NUL-terminated */
if (buf_ensure_space(buf, 2))
buf_error(buf);
return buf_error(buf);
buf->data[buf->pos] = buf->data[buf->pos + 1] = 0;

return len;
Expand Down

0 comments on commit 5cfe6f8

Please sign in to comment.