diff options
author | Tom Hacohen <tom@stosb.com> | 2014-05-16 14:27:39 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2014-05-16 14:28:57 +0100 |
commit | 831c20464d212fde8d6ee125342e90e5e64efc1e (patch) | |
tree | b999c6735414abf091e2c1fdb22b48fd5df6db79 | |
parent | 9cfb0500223e2b07fbab27f16c841e59d2fc249d (diff) | |
download | efl-831c20464d212fde8d6ee125342e90e5e64efc1e.tar.gz |
Eo: Fix deref after free.
In some rare cases it was possible for a pointer to be referenced after
it was already freed. This is now fixed thanks to coverity.
@fix
CID 1039898
-rw-r--r-- | src/lib/eo/eo_base_class.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index 21d7d2dc86..af7a424e7e 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -430,11 +430,10 @@ struct _Eo_Callback_Description static void _eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) { - Eo_Callback_Description *itr, *pitr; + Eo_Callback_Description *itr, *pitr, *base; - itr = pitr = pd->callbacks; - if (pd->callbacks == cb) - pd->callbacks = cb->next; + base = itr = pd->callbacks; + pitr = NULL; for ( ; itr; ) { @@ -447,6 +446,11 @@ _eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) { pitr->next = titr->next; } + else + { + /* If pitr is NULL, it means we need to update base. */ + base = titr->next; + } free(titr); } else @@ -454,6 +458,8 @@ _eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb) pitr = titr; } } + + pd->callbacks = base; } /* Actually remove, doesn't care about walking list, or delete_me */ |