diff mbox

opensm/st.c: fix potential core dumps

Message ID 4C8657D1.40900@mellanox.co.il (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Yevgeny Kliteynik Sept. 7, 2010, 3:18 p.m. UTC
None
diff mbox

Patch

diff --git a/opensm/opensm/st.c b/opensm/opensm/st.c
index ea76038..469ba9d 100644
--- a/opensm/opensm/st.c
+++ b/opensm/opensm/st.c
@@ -194,6 +194,8 @@  size_t size;
 #endif

 	size = new_size(size);	/* round up to prime number */
+	if (size < 0)
+		return NULL;

 	tbl = alloc(st_table);
 	tbl->type = type;
@@ -351,6 +353,9 @@  register st_table *table;
 	unsigned int hash_val;

 	new_num_bins = new_size(old_num_bins + 1);
+	if (new_num_bins < 0)
+		return;
+
 	new_bins =
 	    (st_table_entry **) Calloc(new_num_bins, sizeof(st_table_entry *));