瀏覽代碼

Null termnate the pUserMappings variable to prevent memory corruption.

Sam Lantinga 11 年之前
父節點
當前提交
ab9345a896
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      src/joystick/SDL_gamecontroller.c

+ 1 - 0
src/joystick/SDL_gamecontroller.c

@@ -835,6 +835,7 @@ SDL_GameControllerLoadHints()
         char *pUserMappings = SDL_malloc( nchHints + 1 );
         char *pUserMappings = SDL_malloc( nchHints + 1 );
         char *pTempMappings = pUserMappings;
         char *pTempMappings = pUserMappings;
         SDL_memcpy( pUserMappings, hint, nchHints );
         SDL_memcpy( pUserMappings, hint, nchHints );
+        pUserMappings[nchHints] = '\0';
         while ( pUserMappings ) {
         while ( pUserMappings ) {
             char *pchNewLine = NULL;
             char *pchNewLine = NULL;