Bug in erl_interface 3.3.0 (with fix)

Kent Boortz <>
Fri Apr 5 18:40:23 CEST 2002


Hans Nilsson <> writes:
> 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.

Thank you for the patch. I can't find the reason why this function
does not follow the safer coding pattern of the ei_x_encode_*
functions in "ei_x_encode.c", i.e. why it was not written like

  int ei_x_encode_term(ei_x_buff* x, void* t)
  {
      int i = x->index;
      ei_encode_term(NULL, &i, t);
      if (!x_fix_buff(x, i))
          return -1;
      return ei_encode_term(x->buff, &x->index, t);
  }

kent



More information about the erlang-questions mailing list