Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 1f4d2fc. rdar://problem/105801362
Cherry-pick 252432.1031@safari-7614-branch (9f7e401). rdar://103852510 Fix use-after-free in DFGFixupPhase for array indexOf https://bugs.webkit.org/show_bug.cgi?id=250429 rdar://103852510 Reviewed by Jonathan Bedard and Michael Saboff. During DFG fixup, array indexOf nodes are folded to -1 when the search element is speculated to be a different type than the array element (for instance, JSCell instead of Int32). When this happens, a speculation check is inserted, which can cause the DFG graph's varArgChildren array to reallocate. This invalidates the searchElement Edge reference, which we use immediately after the check insertion in the fixup phase. This patch fixes this potential use-after-free by grabbing the searchElement's associated node before inserting any checks, giving us a persistent pointer to a DFG node rather than a reference into a vector. * JSTests/stress/cell-speculated-array-indexof.js: Added. * Source/JavaScriptCore/dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupArrayIndexOf): Canonical link: https://commits.webkit.org/252432.1031@safari-7614-branch Canonical link: https://commits.webkit.org/259548.18@safari-7615-branch Canonical link: https://commits.webkit.org/245886.857@safari-7613.4.1.0-branch
- Loading branch information