From 366114238332831b5dc68eb34bbd985ab2d7fbd0 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sat, 23 Apr 2011 20:01:03 -0700 Subject: [PATCH] handle an edge case in dlist_repr --- src/dlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dlist.c b/src/dlist.c index 12ee743..5969f16 100644 --- a/src/dlist.c +++ b/src/dlist.c @@ -31,13 +31,18 @@ char *dlist_repr(LakeDottedList *dlist) GString *s = g_string_new("("); int i; char *s2; - if (dlist->head) { + if (dlist->head && LIST_N(dlist->head)) { for (i = 0; i < LIST_N(dlist->head); ++i) { s2 = lake_repr(LIST_VAL(dlist->head, i)); g_string_append(s, s2); g_free(s2); if (i != LIST_N(dlist->head) - 1) g_string_append(s, " "); } + } + else if (dlist->head) { + s2 = lake_repr(VAL(dlist->head)); + g_string_append(s, s2); + g_free(s2); } g_string_append(s, " . "); s2 = lake_repr(dlist->tail);