Bug in erl_interface 3.3.0 (with fix)

Hans Nilsson hans@REDACTED
Fri Apr 5 17:20:18 CEST 2002


Hi,

In encode_term.c in erl_interface 3.3.0 (open source erlang R8B-0) there 
is a bug in the function ei_x_encode_term.

32c32
<     if (!x_fix_buff(x, i))
---
>     if (!x_fix_buff(x, (i+erl_term_len(t))    ))


With this patch it will calculate the size of the needed area before
checking the area size.

The changed function is like this after the fix:

int ei_x_encode_term(ei_x_buff* x, void* t)
{
    int i = x->index;
    char* s, * s0;

    if (!x_fix_buff(x, (i+erl_term_len(t))    ))
	return -1;
    s0 = s = x->buff + i;
    i += erl_term_len(t) - 1;
    if (erl_encode_it(t,(unsigned char **)&s, 5))
	return -1;
    x->index += s - s0;
    return 0;
}


By the way, couldn't "i += erl_term_len(t) - 1;" be removed?

/Hans







More information about the erlang-questions mailing list