SDL_mixer: examples/playmus: Prevent stack smashing on long input strings (8a0af)

From 8a0af850229ab464d10a3e964282386fb6341628 Mon Sep 17 00:00:00 2001
From: Tasos Sahanidis <[EMAIL REDACTED]>
Date: Thu, 8 Feb 2024 04:43:03 +0200
Subject: [PATCH] examples/playmus: Prevent stack smashing on long input
 strings

In addition, fflush(stdin) is undefined behaviour, so remove it.

(cherry picked from commit ef5373696f3a3bfd90e98be0a145196b7118a665)
---
 playmus.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/playmus.c b/playmus.c
index bd59e5c8..b31f7f99 100644
--- a/playmus.c
+++ b/playmus.c
@@ -73,8 +73,7 @@ void Menu(void)
     char buf[10];
 
     printf("Available commands: (p)ause (r)esume (h)alt volume(v#) > ");
-    fflush(stdin);
-    if (scanf("%s",buf) == 1) {
+    if (fgets(buf, sizeof(buf), stdin)) {
         switch(buf[0]) {
 #if defined(SEEK_TEST)
         case '0': Mix_SetMusicPosition(0); break;