We assume no values is unlikely, since we have been dereferencing
->values[0] forever, with no known reports of trouble.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
el2 = ldb_msg_find_element(*msg2, ac->attributeName);
/*
- * NULL elements sort at the end (regardless of ac->reverse flag).
+ * NULL and empty elements sort at the end (regardless of ac->reverse flag).
+ * NULL elements come after empty ones.
*/
if (el1 == NULL && el2 == NULL) {
return 0;
if (el2 == NULL) {
return -1;
}
+ if (unlikely(el1->num_values == 0 && el2->num_values == 0)) {
+ return 0;
+ }
+ if (unlikely(el1->num_values == 0)) {
+ return 1;
+ }
+ if (unlikely(el2->num_values == 0)) {
+ return -1;
+ }
if (ac->reverse)
return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);