think i found the bug.
it triggers a segfault only when compiled with optimization enabled (-DWITH_DEBUG switches off optimization).
the bug causes the return address from main to be corrupted resulting in a segfault,
here's a patch, put this in /usr/ports/sysutils/freecolor/files/patch-freecolor.c:
Code:
--- freecolor.c.bak 2005-10-19 01:39:52.000000000 +0530
+++ freecolor.c 2008-06-28 19:16:13.000000000 +0530
@@ -62,9 +62,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#ifndef NO_GETOPT
-#include <getopt.h>
-#endif
#define BARLEN 35
#define HEADERLEN 14
#define VERSION "0.8.7"
@@ -76,9 +73,9 @@
void bargraph(float percent, float secondper, char marks[BARLEN+HEADERLEN],int usefull) {
char percentone[BARLEN], percenttwo[BARLEN], remain[BARLEN];
unsigned int numberofmarks, numofmarkstwo, remainnum;
- numberofmarks=(int) ((float) (BARLEN*(percent/100)));
- if (!usefull) numofmarkstwo=(int) ((float) (BARLEN*(secondper/100))); else numofmarkstwo=(BARLEN-numberofmarks);
- remainnum=BARLEN-(numberofmarks+numofmarkstwo);
+ numberofmarks=(int) ((float) ((BARLEN-1)*(percent/100)));
+ if (!usefull) numofmarkstwo=(int) ((float) ((BARLEN-1)*(secondper/100))); else numofmarkstwo=((BARLEN-1)-numberofmarks);
+ remainnum=(BARLEN-1)-(numberofmarks+numofmarkstwo);
memset(percentone, '#', numberofmarks);
memset(percenttwo, '%', numofmarkstwo);
memset(remain, '.', remainnum);