Fix Savane bug #64581

This reverts commit 4f3824743f.
This commit is contained in:
Sergey Poznyakoff
2023-08-22 18:18:31 +03:00
parent a9a8990fb3
commit 5114218025

View File

@@ -472,7 +472,7 @@ wsnode_remove (struct wordsplit *wsp, struct wordsplit_node *node)
static struct wordsplit_node * static struct wordsplit_node *
wsnode_tail (struct wordsplit_node *p) wsnode_tail (struct wordsplit_node *p)
{ {
while (p->next) while (p && p->next)
p = p->next; p = p->next;
return p; return p;
} }
@@ -572,15 +572,15 @@ coalesce_segment (struct wordsplit *wsp, struct wordsplit_node *node)
size_t len = 0; size_t len = 0;
char *buf, *cur; char *buf, *cur;
for (p = node; p->flags & _WSNF_JOIN; ) if (!(node->flags & _WSNF_JOIN))
return 0;
for (p = node; p && (p->flags & _WSNF_JOIN); p = p->next)
{ {
len += wsnode_len (p); len += wsnode_len (p);
p = p->next;
if (!p)
break;
} }
if (p == node) if (p)
return 0; len += wsnode_len (p);
end = p; end = p;
buf = malloc (len + 1); buf = malloc (len + 1);