Mesa (master): glsl: Fix null access on file read error

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 7 15:26:49 UTC 2014


Module: Mesa
Branch: master
Commit: 88cad8356eadde7b6bc25cc5a0c1762352e5b3f7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=88cad8356eadde7b6bc25cc5a0c1762352e5b3f7

Author: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Date:   Fri Feb  7 14:43:59 2014 +0200

glsl: Fix null access on file read error

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Reviewed-by: Brian Paul <brianp at vmware.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 5ea57d5..3a0f812 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -232,7 +232,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) {
@@ -243,6 +243,7 @@ load_text_file(void *ctx, const char *file_name)
 		} while (total_read < size);
 
 		text[total_read] = '\0';
+error:;
 	}
 
 	fclose(fp);




More information about the mesa-commit mailing list