bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 02/14] libtrivfs: improve the out of memory handling in add_el


From: Justus Winter
Subject: [PATCH 02/14] libtrivfs: improve the out of memory handling in add_el
Date: Fri, 8 Nov 2013 21:24:10 +0100

add_el reallocs two memory regions. If at least one of the operation
fails, free any region that was successfully resized. Also release the
lock.

Found using the Clang Static Analyzer.

* libtrivfs/dyn-classes.c (add_el): Improve the oom handling.
---
 libtrivfs/dyn-classes.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/libtrivfs/dyn-classes.c b/libtrivfs/dyn-classes.c
index a6bb7de..981a588 100644
--- a/libtrivfs/dyn-classes.c
+++ b/libtrivfs/dyn-classes.c
@@ -104,6 +104,9 @@ add_el (void *el, void (*free_el)(),
     {
       if (free_el)
        (*free_el) (el);
+      free (new_vec);
+      free (new_aux_vec);
+      pthread_mutex_unlock (&dyn_lock);
       /* One of the vectors might be the wrong size, but who cares.  */
       return ENOMEM;
     }
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]