[erlang-bugs] erlang:binary_to_term/1 does not correctly decode LIST_EXT records of length 0

Matthew Dempsky matthew@REDACTED
Tue Mar 31 05:26:11 CEST 2009


>From my reading of the External Term Format chapter of the erts
manual, a LIST_EXT record should still have a Tail field even when
Length = 0.  However, in R12B-3 and R13A, a LIST_EXT record with
Length = 0 is decoded to just [] without examining Tail at all.  For
example:

> binary_to_term(<<131,$h,2,$l,0:32,$j,$a,42>>).
{[],[]}

The patch below changes this to what I believe is correct behavior:

> binary_to_term(<<131,$h,2,$l,0:32,$j,$a,42>>).
{[],42}


--- external.c.orig	2009-03-30 19:35:39.000000000 -0700
+++ external.c	2009-03-30 20:01:19.000000000 -0700
@@ -1099,7 +1099,7 @@
 	    n = get_int32(ep);
 	    ep += 4;
 	    if (n == 0) {
-		*objp = NIL;
+		next = objp;
 		break;
 	    }
 	    *objp = make_list(hp);



More information about the erlang-bugs mailing list