fix NIL case

This commit is contained in:
Seven Du 2012-10-23 10:44:31 +08:00
parent 4b6db1329c
commit 5ff654dab5
1 changed files with 5 additions and 0 deletions

View File

@ -305,6 +305,11 @@ int ei_decode_string_or_binary(char *buf, int *index, int maxlen, char *dst)
ei_get_type(buf, index, &type, &size); ei_get_type(buf, index, &type, &size);
if (type == ERL_NIL_EXT || size == 0) {
dst[0] = '\0';
return 0;
}
if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) { if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) {
return -1; return -1;
} else if (size > maxlen) { } else if (size > maxlen) {