Mesa (master): glsl/pp: Add asserts to check for null pointer deferences.

Vinson Lee vlee at kemper.freedesktop.org
Mon Feb 15 00:31:09 PST 2010


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

Author: Vinson Lee <vlee at vmware.com>
Date:   Mon Feb 15 00:30:31 2010 -0800

glsl/pp: Add asserts to check for null pointer deferences.

---

 src/glsl/pp/sl_pp_extension.c |    4 ++++
 src/glsl/pp/sl_pp_process.c   |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/glsl/pp/sl_pp_extension.c b/src/glsl/pp/sl_pp_extension.c
index 2b6cf3c..677fb8a 100644
--- a/src/glsl/pp/sl_pp_extension.c
+++ b/src/glsl/pp/sl_pp_extension.c
@@ -137,6 +137,7 @@ sl_pp_process_extension(struct sl_pp_context *context,
          return -1;
       }
       out.token = SL_PP_EXTENSION_REQUIRE;
+      assert(extension);
       extension->enabled = 1;
    } else if (behavior == context->dict.enable) {
       if (out.data.extension == -1) {
@@ -148,6 +149,7 @@ sl_pp_process_extension(struct sl_pp_context *context,
          return -1;
       }
       out.token = SL_PP_EXTENSION_ENABLE;
+      assert(extension);
       extension->enabled = 1;
    } else if (behavior == context->dict.warn) {
       if (out.data.extension == -1) {
@@ -155,6 +157,7 @@ sl_pp_process_extension(struct sl_pp_context *context,
          return 0;
       }
       out.token = SL_PP_EXTENSION_WARN;
+      assert(extension);
       extension->enabled = 1;
    } else if (behavior == context->dict.disable) {
       if (out.data.extension == -1) {
@@ -162,6 +165,7 @@ sl_pp_process_extension(struct sl_pp_context *context,
          return 0;
       }
       out.token = SL_PP_EXTENSION_DISABLE;
+      assert(extension);
       extension->enabled = 0;
    } else {
       strcpy(context->error_msg, "unrecognised behavior name");
diff --git a/src/glsl/pp/sl_pp_process.c b/src/glsl/pp/sl_pp_process.c
index f89986d..315ad9b 100644
--- a/src/glsl/pp/sl_pp_process.c
+++ b/src/glsl/pp/sl_pp_process.c
@@ -87,6 +87,7 @@ sl_pp_process_get(struct sl_pp_context *context,
       int found_eof = 0;
 
       if (context->process_state.out_len) {
+         assert(context->process_state.out);
          *output = context->process_state.out[0];
 
          if (context->process_state.out_len > 1) {



More information about the mesa-commit mailing list