mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-17 18:16:52 +00:00
libsemanage: do not sort empty records
Do not sort empty records to avoid calling qsort(3) with a NULL pointer. qsort(3) might be annotated with the function attribute nonnull and UBSan then complains: database_join.c:80:2: runtime error: null pointer passed as argument 1, which is declared to never be null Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
parent
b98d3c4c53
commit
ea539017fb
@ -77,10 +77,14 @@ static int dbase_join_cache(semanage_handle_t * handle, dbase_join_t * dbase)
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* Sort for quicker merge later */
|
/* Sort for quicker merge later */
|
||||||
qsort(records1, rcount1, sizeof(record1_t *),
|
if (rcount1 > 0) {
|
||||||
(int (*)(const void *, const void *))rtable1->compare2_qsort);
|
qsort(records1, rcount1, sizeof(record1_t *),
|
||||||
qsort(records2, rcount2, sizeof(record2_t *),
|
(int (*)(const void *, const void *))rtable1->compare2_qsort);
|
||||||
(int (*)(const void *, const void *))rtable2->compare2_qsort);
|
}
|
||||||
|
if (rcount2 > 0) {
|
||||||
|
qsort(records2, rcount2, sizeof(record2_t *),
|
||||||
|
(int (*)(const void *, const void *))rtable2->compare2_qsort);
|
||||||
|
}
|
||||||
|
|
||||||
/* Now merge into this dbase */
|
/* Now merge into this dbase */
|
||||||
while (i < rcount1 || j < rcount2) {
|
while (i < rcount1 || j < rcount2) {
|
||||||
|
Loading…
Reference in New Issue
Block a user