Skip to content

Commit 5e78f08

Browse files
fix example of bare_api, check empty string
1 parent 13bb132 commit 5e78f08

File tree

1 file changed

+1
-0
lines changed
  • examples/host/bare_api/src

1 file changed

+1
-0
lines changed

examples/host/bare_api/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ static int _count_utf8_bytes(const uint16_t *buf, size_t len) {
410410
}
411411

412412
static void print_utf16(uint16_t *temp_buf, size_t buf_len) {
413+
if ((temp_buf[0] & 0xff) == 0) return; // empty
413414
size_t utf16_len = ((temp_buf[0] & 0xff) - 2) / sizeof(uint16_t);
414415
size_t utf8_len = (size_t) _count_utf8_bytes(temp_buf + 1, utf16_len);
415416
_convert_utf16le_to_utf8(temp_buf + 1, utf16_len, (uint8_t *) temp_buf, sizeof(uint16_t) * buf_len);

0 commit comments

Comments
 (0)