All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] uintset: Fix memory leak in l_uintset_new_from_range
@ 2015-10-21 21:13 Szymon Janc
  2015-10-21 21:13 ` [PATCH 2/4] ringbuf: Remove dead code Szymon Janc
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Szymon Janc @ 2015-10-21 21:13 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 713 bytes --]

Allocate ret only after checking size parameter.
---
 ell/uintset.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ell/uintset.c b/ell/uintset.c
index 3d9c8e3..4547ac9 100644
--- a/ell/uintset.c
+++ b/ell/uintset.c
@@ -149,12 +149,13 @@ struct l_uintset {
 LIB_EXPORT struct l_uintset *l_uintset_new_from_range(uint32_t min,
 								uint32_t max)
 {
-	struct l_uintset *ret = l_new(struct l_uintset, 1);
+	struct l_uintset *ret;
 	unsigned int size = max - min + 1;
 
 	if (size > USHRT_MAX)
 		return NULL;
 
+	ret = l_new(struct l_uintset, 1);
 	ret->bits = l_new(unsigned long,
 				(size + BITS_PER_LONG - 1) / BITS_PER_LONG);
 	ret->size = size;
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-21 23:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-21 21:13 [PATCH 1/4] uintset: Fix memory leak in l_uintset_new_from_range Szymon Janc
2015-10-21 21:13 ` [PATCH 2/4] ringbuf: Remove dead code Szymon Janc
2015-10-21 21:13 ` [PATCH 3/4] unit: Add tests for NULL set in uintset Szymon Janc
2015-10-21 21:13 ` [PATCH 4/4] uintset: Fix crash on NULL set Szymon Janc
2015-10-21 23:25 ` [PATCH 1/4] uintset: Fix memory leak in l_uintset_new_from_range Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.