1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ldb:mod:sort: rearrange NULL checks

There are further changes coming here.

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>
(cherry picked from commit d785c1991c)
This commit is contained in:
Douglas Bagnall 2024-04-07 14:54:34 +12:00 committed by Jule Anger
parent faed55f4f8
commit 5f52991b93

View File

@ -121,15 +121,18 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
el1 = ldb_msg_find_element(*msg1, ac->attributeName);
el2 = ldb_msg_find_element(*msg2, ac->attributeName);
if (!el1 && el2) {
/*
* NULL elements sort at the end (regardless of ac->reverse flag).
*/
if (el1 == NULL && el2 == NULL) {
return 0;
}
if (el1 == NULL) {
return 1;
}
if (el1 && !el2) {
if (el2 == NULL) {
return -1;
}
if (!el1 && !el2) {
return 0;
}
if (ac->reverse)
return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);