diff options
author | LAN-TW <lantw44@gmail.com> | 2013-12-08 00:06:15 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2013-12-08 00:06:15 +0800 |
commit | a464ef5069efe62074a5b4d6af8e3e831bc52bd0 (patch) | |
tree | 2c646fcf2e988ec26f16905b58e03eef76a9a1e7 | |
parent | 06159197d374e33d37aaaaed2b8b603cd65a270d (diff) | |
download | l4basic-a464ef5069efe62074a5b4d6af8e3e831bc52bd0.tar.gz l4basic-a464ef5069efe62074a5b4d6af8e3e831bc52bd0.tar.zst l4basic-a464ef5069efe62074a5b4d6af8e3e831bc52bd0.zip |
Check NULL pointer before unref
-rw-r--r-- | l4array.c | 6 | ||||
-rw-r--r-- | l4array2.c | 3 |
2 files changed, 9 insertions, 0 deletions
@@ -103,6 +103,9 @@ void* lbs_array_ref_generic (void* array_generic) { } void lbs_array_unref_generic (void* array_generic) { + if (array_generic == NULL) { + return; + } LbsArray* array = LBS_ARRAY (array_generic); array->ref_count--; if (array->ref_count <= 0) { @@ -111,6 +114,9 @@ void lbs_array_unref_generic (void* array_generic) { } void lbs_array_free_generic (void* array_generic) { + if (array_generic == NULL) { + return; + } LbsArray* array = LBS_ARRAY (array_generic); if (array->free_func != NULL) { int i = 0; @@ -37,6 +37,9 @@ void* lbs_array2_ref_generic (void* array2_generic) { } void lbs_array2_unref_generic (void* array2_generic) { + if (array2_generic == NULL) { + return; + } LbsArray2* array2 = LBS_ARRAY2 (array2_generic); array2->ref_count--; if (array2->ref_count <= 0) { |