SDL_mixer: examples/playmus: Prevent stack smashing on long input strings

From ef5373696f3a3bfd90e98be0a145196b7118a665 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.
---
 examples/playmus.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/examples/playmus.c b/examples/playmus.c
index 85e5fc27..03af89d4 100644
--- a/examples/playmus.c
+++ b/examples/playmus.c
@@ -72,8 +72,7 @@ static 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;