From 3e7b0c29165114d543669bb00793920412f37c08 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 Jun 2014 10:44:29 +0300 Subject: [PATCH] Fix crash when GL nodes file cannot be opened for writing Report errors to console if nodes file cannot be opened or written --- src/p_glnodes.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index a8fa04c34..e59f3859a 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1168,8 +1168,21 @@ static void CreateCachedNodes(MapData *map) FString path = CreateCacheName(map, true); FILE *f = fopen(path, "wb"); - fwrite(compressed, 1, outlen+offset, f); - fclose(f); + + if (f != NULL) + { + if (fwrite(compressed, outlen+offset, 1, f) != 1) + { + Printf("Error saving nodes to file %s\n", path.GetChars()); + } + + fclose(f); + } + else + { + Printf("Cannot open nodes file %s for writing\n", path.GetChars()); + } + delete [] compressed; }