Skip to content

Commit

Permalink
Fix integer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
niclas committed Jan 24, 2019
1 parent 8b38e13 commit e275564
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions xdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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];
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit e275564

Please sign in to comment.