tvb_unicode_strsize() returns number of bytes, NOT number of UCS-2 characters.

svn path=/trunk/; revision=42622
This commit is contained in:
Jakub Zawadzki 2012-05-14 06:32:16 +00:00
parent 14b616c35d
commit 0f1a21aaa9
2 changed files with 3 additions and 5 deletions

View File

@ -2020,7 +2020,7 @@ tvb_strsize(tvbuff_t *tvb, const gint offset)
}
/* UTF-16/UCS-2 version of tvb_strsize */
/* Returns number of *16-bit units* (not bytes) including the null terminator */
/* Returns number of bytes including the (two-bytes) null terminator */
guint
tvb_unicode_strsize(tvbuff_t *tvb, const gint offset)
{
@ -2035,7 +2035,7 @@ tvb_unicode_strsize(tvbuff_t *tvb, const gint offset)
i += 2;
} while(uchar != 0);
return i; /* Number of *16-bit units* */
return i;
}
/* Find length of string by looking for end of string ('\0'), up to

View File

@ -100,9 +100,7 @@ WSLUA_METHOD TreeItem_add_packet_field(lua_State *L) {
case ENC_UTF_16:
case ENC_UCS_2:
/* tvb_unicode_strsize() returns a count of 16-bit
values; we need a count of bytes */
tvbr->len = (tvb_unicode_strsize (tvbr->tvb->ws_tvb, tvbr->offset)) * 2;
tvbr->len = tvb_unicode_strsize (tvbr->tvb->ws_tvb, tvbr->offset);
break;
default: