summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_imm_alloc.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-05-09 13:53:36 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-05-09 13:53:36 +0000
commitbcf749e83a4844972b8fbb84e9762a9b1ec77c5f (patch)
tree095ccd846c8bc7b02f9363506f2e1f8e8f26ca8c /src/mesa/tnl/t_imm_alloc.c
parent335634b807921285bec0709ee92c454cee87ee88 (diff)
fix possible segfault on destroy context
Diffstat (limited to 'src/mesa/tnl/t_imm_alloc.c')
-rw-r--r--src/mesa/tnl/t_imm_alloc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c
index 2b497a7058..22bdb7a7bb 100644
--- a/src/mesa/tnl/t_imm_alloc.c
+++ b/src/mesa/tnl/t_imm_alloc.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_alloc.c,v 1.7 2001/04/30 21:08:52 keithw Exp $ */
+/* $Id: t_imm_alloc.c,v 1.8 2001/05/09 13:53:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -118,14 +118,21 @@ struct immediate *_tnl_alloc_immediate( GLcontext *ctx )
return real_alloc_immediate( ctx );
}
+/* May be called after tnl is destroyed.
+ */
void _tnl_free_immediate( struct immediate *IM )
{
TNLcontext *tnl = TNL_CONTEXT(IM->backref);
ASSERT(IM->ref_count == 0);
- if (tnl->freed_immediate)
- real_free_immediate( tnl->freed_immediate );
-
- tnl->freed_immediate = IM;
+ if (!tnl) {
+ real_free_immediate( IM );
+ }
+ else {
+ if (tnl->freed_immediate)
+ real_free_immediate( tnl->freed_immediate );
+
+ tnl->freed_immediate = IM;
+ }
}