diff options
-rw-r--r-- | src/level.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/level.c b/src/level.c index b68c85f..7349e23 100644 --- a/src/level.c +++ b/src/level.c @@ -40,8 +40,20 @@ db_level_new(const char *game_id, const char *level_id, struct db_level *prev) return NULL; } - level->game_id = strdup(game_id); + level->game_id = strdup(game_id); + if (level->game_id == NULL) { + db_err("Failed to allocate memory"); + free(level); + return NULL; + } + level->level_id = strdup(level_id); + if (level->level_id == NULL) { + db_err("Failed to allocate memory"); + free(level->game_id); + free(level); + return NULL; + } if (prev != NULL) { prev->next = level; |