From fb13e652fa082be98f4dceb02041178a03560362 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 13 Nov 2022 19:41:32 -0800 Subject: [PATCH] Check for `SDL_strdup` failure in `parseComments` Just in case it happens. Comments aren't really important to the game (at worst a track will just loop in the wrong place) so it's fine to carry on here and ignore all comments if this happens. --- desktop_version/src/Music.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index fa0513c3..6aa16757 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -484,6 +484,14 @@ end: for (int i = 0; i < comment_list_length; i++) { char* param = SDL_strdup(comments[i]); + if (param == NULL) + { + vlog_error( + "Could not allocate memory to parse '%s'. Ignoring comments.", + comments[i] + ); + break; + } char* argument = param; char* value = SDL_strchr(param, '='); if (value == NULL)