Closed Bug 532454 Opened 16 years ago Closed 15 years ago

Sort implementation incorrectly converts result of program-supplied comparison function to integer

Categories

(Tamarin Graveyard :: Library, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED
Q3 11 - Serrano

People

(Reporter: lhansen, Assigned: wmaddox)

Details

(Whiteboard: must-fix-candidate)

Attachments

(1 file)

See ArraySort::ScriptCompare in ArrayClass.cpp: it calls toInteger on the return value from the user function, /even though there is a comment there that says not to do that/. This breaks the obvious user function that subtracts one element from the other. TC, these should both produce elements in ascending order: var nonWorkingCompare:Function = function(x:Number, y:Number):Number { return x - y; }; var workingCompare:Function = function(x:Number, y:Number):Number { if (x < y) return -1; if (x > y) return 1; return 0; }; trace([5.5, 3.1, 4.9, 4].sort(nonWorkingCompare)); // 3.1,4.9,5.5,4 trace([5.5, 3.1, 4.9, 4].sort(workingCompare)); // 3.1,4,4.9,5.5
Flags: in-testsuite?
Flags: flashplayer-needsversioning+
Component: Virtual Machine → Library
Flags: in-testsuite?
OS: Mac OS X → All
Priority: -- → P2
QA Contact: vm → library
Hardware: x86 → All
Target Milestone: Future → flash10.2
Assignee: nobody → wmaddox
Broken for both Array and Vector. Also came in via https://bugs.adobe.com/jira/browse/ASL-174.
Status: NEW → ASSIGNED
Flags: flashplayer-bug+
Whiteboard: must–fix-candidate
Whiteboard: must–fix-candidate → must-fix-candidate
Attached patch Versioned fix — — Splinter Review
Fix follows the pattern set by a disturbingly similar issue previously fixed, bug 524122.
Flags: flashplayer-qrb+
Flags: flashplayer-injection-
Attachment #527900 - Flags: review?(stejohns)
Comment on attachment 527900 [details] [diff] [review] Versioned fix Review of attachment 527900 [details] [diff] [review]: Looks right.
Attachment #527900 - Flags: review?(stejohns) → review+
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: