From 60a34c1cd0e7e5b51bb83a07ffa2cae869eb0179 Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Mon, 28 Oct 2013 18:23:02 +0900 Subject: [PATCH] eina: avoid possible race condition when unreffing an Eina_File. --- src/lib/eina/eina_file_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c index ac7d020..e5b1250 100644 --- a/src/lib/eina/eina_file_common.c +++ b/src/lib/eina/eina_file_common.c @@ -445,12 +445,15 @@ eina_file_dup(Eina_File *file) EAPI void eina_file_close(Eina_File *file) { + Eina_Bool leave = EINA_TRUE; + EINA_SAFETY_ON_NULL_RETURN(file); eina_lock_take(&file->lock); file->refcount--; + if (file->refcount == 0) leave = EINA_FALSE; eina_lock_release(&file->lock); - if (file->refcount != 0) return; + if (leave) return; eina_lock_take(&_eina_file_lock_cache); -- 2.7.4