diff options
author | Roland Dreier <rolandd@cisco.com> | 2006-06-01 23:16:18 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:36:33 -0800 |
commit | c66b5f1057623b78c3db911d7aab506ec475fa6b (patch) | |
tree | 45cbeb2391fbf9907fb28714aba74e68c731caf8 | |
parent | a82618177859823e781fad820b1227607b2b1254 (diff) | |
download | libibverbs-c66b5f1057623b78c3db911d7aab506ec475fa6b.tar.gz |
Fix ibv_get_device_list() to really NULL-terminate the array
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/device.c | 2 |
2 files changed, 8 insertions, 3 deletions
@@ -1,8 +1,13 @@ +2006-06-01 Roland Dreier <rdreier@cisco.com> + + * src/device.c (ibv_get_device_list): Actually return a + NULL-terminated array as the documentation promises. + 2006-05-31 Roland Dreier <rdreier@cisco.com> * src/init.c (find_drivers), src/device.c (ibv_open_device): Fix - memleaks: the result of asprintf() needs to be freed when we're - done with it. + memory leaks: the result of asprintf() needs to be freed when + we're done with it. * examples/asyncwatch.c (event_name_str): Print human-readable form of IBV_EVENT_CLIENT_REREGISTER. diff --git a/src/device.c b/src/device.c index 4eee31c..4ceb640 100644 --- a/src/device.c +++ b/src/device.c @@ -63,7 +63,7 @@ struct ibv_device **ibv_get_device_list(int *num) if (!num_devices) num_devices = ibverbs_init(&device_list); - l = calloc(num_devices, sizeof (struct ibv_device *)); + l = calloc(num_devices + 1, sizeof (struct ibv_device *)); for (i = 0; i < num_devices; ++i) l[i] = device_list[i]; |