From 6f1d4e1d5cc864a4c6d1f9b90a761342c5b19be5 Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Sat, 2 Nov 2024 18:09:49 +0000 Subject: [PATCH] fix: null-terminate versionSubstring in OGLGetDriverVersion --- desmume/src/OGLRender.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index b78d309ec..493cace53 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -733,7 +733,8 @@ static void OGLGetDriverVersion(const char *oglVersionString, } // Copy the version substring and parse it. - char *versionSubstring = (char *)malloc(versionStringLength * sizeof(char)); + char *versionSubstring = (char *)malloc((versionStringLength + 1) * sizeof(char)); + versionSubstring[versionStringLength] = '\0'; strncpy(versionSubstring, versionStrStart, versionStringLength); unsigned int major = 0;