[Mesa-dev] [PATCH] glsl: Fix null access on file read error

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Mon Dec 30 04:20:26 PST 2013


Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/glsl/main.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index aa188b1..755bc9a 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -221,7 +221,7 @@ load_text_file(void *ctx, const char *file_name)
 			if (bytes < size - total_read) {
 				free(text);
 				text = NULL;
-				break;
+				goto error;
 			}
 
 			if (bytes == 0) {
@@ -232,6 +232,7 @@ load_text_file(void *ctx, const char *file_name)
 		} while (total_read < size);
 
 		text[total_read] = '\0';
+error:
 	}
 
 	fclose(fp);
-- 
1.8.1.2



More information about the mesa-dev mailing list