giftcurs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[giFTcurs-devel] division by zero bug


From: Andrzej Szombierski
Subject: [giFTcurs-devel] division by zero bug
Date: Fri, 1 Oct 2004 13:36:15 +0200 (CEST)

While testing my giFT protocol plugin i noticed that giFTcurs crashes when 
displaying some entries in the results window. The cause turned out to be 
a division by zero in format_produce():

                case SPACE:
                        width = k->space_len / k->spaces; <<< here
                        spacefill(str, width);
                        k->space_len -= width;
                        k->spaces--;
                        produced += width;

(gdb) p k->spaces
$25 = 0

The problem lies in format_collect() - it is meant to count all the SPACE 
entries, but this block keeps it from counting:

                if (c.n - c.variable > k->total_len) {
                        c.n = k->total_len + c.variable;
                        break;
                }

I don't know what this code is meant to do, but it makes format_collect 
return spaces==0 even when there are SPACE entries on the list (maybe it 
does other bad things too, but that one makes giFTcurs crash).

I've tested giFTcurs-0.6.2, but the CVS version contains the same code so 
it probably crashes too.

(please CC: me when replying as I'm not subscribed to the list).

-- 
:: Andrzej Szombierski :: address@hidden :: http://kuku.eu.org ::
:: address@hidden  :: radio bez kitu :: http://bezkitu.com ::





reply via email to

[Prev in Thread] Current Thread [Next in Thread]