From 5b5b7ebea68b89c8e918913752ad247f8e946a6f Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 2 Dec 2015 15:25:34 -0500 Subject: [PATCH] core/playlist: Don't calculate an average if count is zero This fixes a divide-by-zero segfault. Signed-off-by: Anna Schumaker --- core/playlist.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/playlist.cpp b/core/playlist.cpp index 6d6030a1..df480a9c 100644 --- a/core/playlist.cpp +++ b/core/playlist.cpp @@ -43,7 +43,10 @@ public: count++; } } - return total / count; + + if (count > 0) + return total / count; + return 0; } void dynamic_add(const std::string &name, Track *track, unsigned int avg)