Free shader-related context state: _mesa_free_shader_state()
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 88aa8c5..002b427 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -212,6 +212,22 @@
 
 
 /**
+ * Free the per-context shader-related state.
+ */
+void
+_mesa_free_shader_state(GLcontext *ctx)
+{
+   if (ctx->Shader.CurrentProgram) {
+      ctx->Shader.CurrentProgram->RefCount--;
+      if (ctx->Shader.CurrentProgram->RefCount <= 0) {
+         _mesa_free_shader_program(ctx, ctx->Shader.CurrentProgram);
+         ctx->Shader.CurrentProgram = NULL;
+      }
+   }
+}
+
+
+/**
  * Copy string from <src> to <dst>, up to maxLength characters, returning
  * length of <dst> in <length>.
  * \param src  the strings source