Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // |reftest| skip-if(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT")) silentfail |
michael@0 | 2 | /* |
michael@0 | 3 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 5 | * |
michael@0 | 6 | * Author: Christian Holler <decoder@own-hero.net> |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | expectExitCode(0); |
michael@0 | 10 | expectExitCode(5); |
michael@0 | 11 | |
michael@0 | 12 | /* Length of 32 */ |
michael@0 | 13 | var foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
michael@0 | 14 | |
michael@0 | 15 | /* Make len(foo) 32768 */ |
michael@0 | 16 | for (i = 0; i < 10; ++i) { |
michael@0 | 17 | foo += foo; |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | /* Add one "a" to cause overflow later */ |
michael@0 | 21 | foo += "a"; |
michael@0 | 22 | |
michael@0 | 23 | var bar = "bbbbbbbbbbbbbbbb"; |
michael@0 | 24 | |
michael@0 | 25 | /* Make len(bar) 8192 */ |
michael@0 | 26 | for (i = 0; i < 9; ++i) { |
michael@0 | 27 | bar += bar; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | /* |
michael@0 | 31 | * Resulting string should be |
michael@0 | 32 | * len(foo) * len(bar) = (2**10 * 32 + 1) * 8192 = 268443648 |
michael@0 | 33 | * which will be larger than the max string length (2**28, or 268435456). |
michael@0 | 34 | */ |
michael@0 | 35 | try { |
michael@0 | 36 | foo.replace(/[a]/g, bar); |
michael@0 | 37 | } catch (e) { |
michael@0 | 38 | reportCompare(e instanceof InternalError, true, "Internal error due to overallocation is ok."); |
michael@0 | 39 | } |
michael@0 | 40 | reportCompare(true, true, "No crash occurred."); |
michael@0 | 41 | |
michael@0 | 42 | print("Tests complete"); |