Skip to content

Commit

Permalink
Do not attempt to divide by zero, if a song is reported as zero long.
Browse files Browse the repository at this point in the history
  • Loading branch information
mywave82 committed Nov 11, 2024
1 parent 38337c6 commit fd44209
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpiface/cpiface.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,12 @@ static void GString_pos_render (const void *inputa, const void *inputb, const vo
case 4: displaystr (lineno, *x, 0x09, "position:", 9); (*x) += 9; break;
}

snprintf (b, 4, "%3d", (int)((*pos) * 100 / (*filesize)));
if ((*filesize)==0)
{
snprintf (b, 4, "NUL");
} else {
snprintf (b, 4, "%3d", (int)((*pos) * 100 / (*filesize)));
}
displaystr (lineno, *x, 0x0f, b, 3); (*x)+=3;
displaychr (lineno, *x, 0x07, '%', 1); (*x)+=1;

Expand Down

0 comments on commit fd44209

Please sign in to comment.