Bug in ei_encode_string_len
Alexey Shchepin
alexey@REDACTED
Mon Oct 20 15:07:37 CEST 2003
Hi!
It seems ei_encode_string_len incorrectly encode string with length
greater than 0xffff. It not append ERL_NIL_EXT in the end of list.
This results in badarg error when this binary processed with
binary_to_term. Below is a patch that should fix this (not tested).
--- encode_string.c.orig Mon Oct 20 13:20:45 2003
+++ encode_string.c Mon Oct 20 13:23:52 2003
@@ -42,7 +42,7 @@
s += len;
}
else {
- if (!buf) s += 5 + (2*len);
+ if (!buf) s += 6 + (2*len);
else {
/* strings longer than 65535 are encoded as lists */
put8(s,ERL_LIST_EXT);
@@ -52,6 +52,8 @@
put8(s,ERL_SMALL_INTEGER_EXT);
put8(s,p[i]);
}
+
+ put8(s,ERL_NIL_EXT);
}
}
More information about the erlang-questions
mailing list