From e275564f56e9ef709f163780bfb7f80d5b2dc6a3 Mon Sep 17 00:00:00 2001 From: Niclas Hofmann Date: Thu, 24 Jan 2019 17:36:18 +0100 Subject: [PATCH] Fix integer overflow --- xdu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xdu.c b/xdu.c index 076c783..37b0a02 100644 --- a/xdu.c +++ b/xdu.c @@ -970,7 +970,7 @@ void fprintpsbox(FILE* fp, int x1, int y1, int x2, int y2) " 10 setmiterlimit\n" " gsave\n" " newpath\n" - " %i %i moveto %i %i lineto %i %i lineto %i %i lineto\n" + " %d %d moveto %d %d lineto %d %d lineto %d %d lineto\n" " closepath\n" " stroke\n" " grestore\n" @@ -994,11 +994,10 @@ void fprintpstext(FILE* fp, int x, int y, char* s) void savepschildren(FILE* fp, struct node* nodep, struct rect rect, int showsize) { - long long totalsize; + long long size, totalsize; int totalheight, height, - top, - size; + top; struct node* np; char *name, label[1024]; @@ -1060,7 +1059,7 @@ void savepschildren(FILE* fp, struct node* nodep, struct rect rect, int showsize savepschildren(fp, np, subrect, showsize); size += np->size; - top = rect.top + (totalsize ? (double)size / (double)totalsize * rect.height + 0.5 : 0); + top = rect.top + (int)(totalsize ? (double)size / (double)totalsize * rect.height + 0.5 : 0); } }