From fd44209c9511879c97bfa427af5f379bd4bb76bb Mon Sep 17 00:00:00 2001 From: Stian Skjelstad Date: Mon, 11 Nov 2024 20:59:32 +0100 Subject: [PATCH] Do not attempt to divide by zero, if a song is reported as zero long. --- cpiface/cpiface.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cpiface/cpiface.c b/cpiface/cpiface.c index afd86e92..e82f8098 100644 --- a/cpiface/cpiface.c +++ b/cpiface/cpiface.c @@ -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;