[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
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, (continued)
- [PATCH 03/14] proc: remove declaration of nested functions from proc.h, Justus Winter, 2013/11/08
- [PATCH 05/14] proc: turn reap into a normal function, Justus Winter, 2013/11/08
- [PATCH 08/14] proc: fix a use-after-free error, Justus Winter, 2013/11/08
- [PATCH 13/14] mach-defpager: include errno.h, Justus Winter, 2013/11/08
- [PATCH 02/14] libtrivfs: improve the out of memory handling in add_el,
Justus Winter <=
- [PATCH 12/14] mach-defpager: turn dealloc_direct into a normal function, Justus Winter, 2013/11/08
- Re: [PATCH 01/14] term: fix error handling in hurdio_mdmctl, Samuel Thibault, 2013/11/09