mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 04:51:26 +12:00
Fix invalid comparator in savedata_op sorting
Some checks failed
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm gcc (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Waiting to run
Build RPCS3 / RPCS3 Mac Intel (push) Waiting to run
Build RPCS3 / RPCS3 Mac Apple Silicon (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang (push) Waiting to run
Generate Translation Template / Generate Translation Template (push) Failing after 1m29s
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Has been skipped
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Has been skipped
Build RPCS3 / RPCS3 FreeBSD (push) Has been skipped
Some checks failed
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm gcc (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Waiting to run
Build RPCS3 / RPCS3 Mac Intel (push) Waiting to run
Build RPCS3 / RPCS3 Mac Apple Silicon (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang (push) Waiting to run
Generate Translation Template / Generate Translation Template (push) Failing after 1m29s
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Has been skipped
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Has been skipped
Build RPCS3 / RPCS3 FreeBSD (push) Has been skipped
According to the C++ standard, comparison functions used in sorting algorithms such as std::sort must establish a strict weak ordering. Specifically, the comparator must be irreflexive: for all values x, comp(x, x) must be false. The original comparator used >= for descending order, which violates this requirement in the case of equal values (i.e., when a == b, both comp(a, b) and comp(b, a) would return true). This can result in undefined behavior in sorting algorithms, including potential segmentation faults due to invalid iterator manipulation. This change replaces >= with > to ensure irreflexivity and compliance with the standard's requirement for a strict weak ordering.
This commit is contained in:
parent
9c93ec0bc3
commit
22d9343f2c
1 changed files with 2 additions and 2 deletions
|
@ -862,11 +862,11 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
|
|||
{
|
||||
if (order == CELL_SAVEDATA_SORTORDER_DESCENT && type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME)
|
||||
{
|
||||
return entry1.mtime >= entry2.mtime;
|
||||
return entry1.mtime > entry2.mtime;
|
||||
}
|
||||
if (order == CELL_SAVEDATA_SORTORDER_DESCENT && type == CELL_SAVEDATA_SORTTYPE_SUBTITLE)
|
||||
{
|
||||
return entry1.subtitle >= entry2.subtitle;
|
||||
return entry1.subtitle > entry2.subtitle;
|
||||
}
|
||||
if (order == CELL_SAVEDATA_SORTORDER_ASCENT && type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue