diff options
author | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2004-08-07 19:22:01 +0000 |
---|---|---|
committer | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2004-08-07 19:22:01 +0000 |
commit | 4a01be711a72d99e054a83e9a00a27b2fc420601 (patch) | |
tree | b83db5c93c997f1579ac1bff7178c67b66ccffac | |
parent | 54c91c33da46e67a4efce0dd43def29c65677ed4 (diff) |
Check to see if array->data is NULL before we dereference it, instead ofXORG-6_7_99_902XORG-6_7_99_901XORG-6_7_99_2XORG-6_7_99_1
after. (Prevents segfault when array->data is initialized to NULL, but
array->length is not set to 0.)
Always initialize both data & length in ARRAYs.
-rw-r--r-- | DAofA8.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* +/* $Xdotorg: $ * $Xorg: DAofA8.c,v 1.4 2001/02/09 02:03:48 xorgcvs Exp $ * * @@ -38,9 +38,11 @@ XdmcpDisposeARRAYofARRAY8 (array) { int i; - for (i = 0; i < (int)array->length; i++) - XdmcpDisposeARRAY8 (&array->data[i]); - if (array->data != NULL) Xfree (array->data); + if (array->data != NULL) { + for (i = 0; i < (int)array->length; i++) + XdmcpDisposeARRAY8 (&array->data[i]); + Xfree (array->data); + } array->length = 0; array->data = NULL; } |