From 7ea2d2024bbdb09805d8719f0163fc23466c75cc Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 10 Apr 2019 01:01:03 +0000 Subject: [PATCH] SW: Fix -Wrestrict git-svn-id: https://svn.eduke32.com/eduke32@7561 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/menus.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index 03e6ac0ff..d874df037 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -2587,8 +2587,12 @@ MNU_InputSmallString(char *name, short pix_width) MNU_MeasureSmallString(name, &w, &h); if (w < pix_width) { - if (strlen(name) < 256) // Dont let it go too far! - sprintf(name, "%s%c", name, ch); + size_t const namelen = strlen(name); + if (namelen < 256) // Dont let it go too far! + { + name[namelen] = ch; + name[namelen+1] = '\0'; + } } } @@ -2687,7 +2691,9 @@ MNU_InputString(char *name, short pix_width) MNU_MeasureString(name, &w, &h); if (w < pix_width) { - sprintf(name, "%s%c", name, ch); + size_t const namelen = strlen(name); + name[namelen] = ch; + name[namelen+1] = '\0'; } }