Re: [ovs-dev] [PATCHv2 2/2] ovn-sbctl: Fix possible null pointer to qsort.

2017-11-01 Thread Ben Pfaff
On Tue, Oct 31, 2017 at 05:29:51PM -0700, William Tu wrote:
> Clang reports possible null pointer 'lflows' passed to qsort.
> This is due to the checker unable to make sure whether 'lflows'
> gets malloc or not in the previous loop.  Fix it by checking the
> 'n_flows' before calling qsort.
> 
> Signed-off-by: William Tu 

Thanks for the patches!  I applied both of these to master.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCHv2 2/2] ovn-sbctl: Fix possible null pointer to qsort.

2017-10-31 Thread William Tu
Clang reports possible null pointer 'lflows' passed to qsort.
This is due to the checker unable to make sure whether 'lflows'
gets malloc or not in the previous loop.  Fix it by checking the
'n_flows' before calling qsort.

Signed-off-by: William Tu 
---
 ovn/utilities/ovn-sbctl.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
index c5ec4e6eaf24..6f3743b55632 100644
--- a/ovn/utilities/ovn-sbctl.c
+++ b/ovn/utilities/ovn-sbctl.c
@@ -860,7 +860,10 @@ cmd_lflow_list(struct ctl_context *ctx)
 lflows[n_flows] = lflow;
 n_flows++;
 }
-qsort(lflows, n_flows, sizeof *lflows, lflow_cmp);
+
+if (n_flows) {
+qsort(lflows, n_flows, sizeof *lflows, lflow_cmp);
+}
 
 bool print_uuid = shash_find(>options, "--uuid") != NULL;
 
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev