Skip to content

Commit de00467

Browse files
committed
Be clearer about ebml_parse_sized_int's sign & endian behavior.
1 parent e6cb7e2 commit de00467

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/format_ebml.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,19 +959,23 @@ static ssize_t ebml_parse_var_int(unsigned char *buffer,
959959
return size;
960960
}
961961

962-
/* Parse a normal int that may be from 1-8 bytes long.
962+
/* Parse a big-endian int that may be from 1-8 bytes long.
963963
* Returns 0 if there's not enough space to read the number;
964964
* Returns -1 if the number is mis-sized.
965965
* Else, returns the length of the number in bytes and writes the
966966
* value to *out_value.
967+
* If is_signed is true, then the int is assumed to be two's complement
968+
* signed, negative values will be correctly promoted, and the returned
969+
* long long can be safely cast to a signed number on systems using
970+
* two's complement arithmatic.
967971
*/
968972
static ssize_t ebml_parse_sized_int(unsigned char *buffer,
969-
unsigned char *buffer_end,
970-
size_t len,
971-
int is_signed,
972-
unsigned long long *out_value)
973+
unsigned char *buffer_end,
974+
size_t len,
975+
int is_signed,
976+
unsigned long long *out_value)
973977
{
974-
long long value;
978+
unsigned long long value;
975979
size_t i;
976980

977981
if (len < 1 || len > 8) {

0 commit comments

Comments
 (0)