# HG changeset patch # User Jeremy Gow # Date 1352851034 0 # Node ID b083ddc5c546917afc51c2eb595a9be7e4797dbc # Parent 01926bcd601676623c7361583f5272a96ede10e9 Sanitise command line input diff -r 01926bcd6016 -r b083ddc5c546 Experiment.class Binary file Experiment.class has changed diff -r 01926bcd6016 -r b083ddc5c546 Experiment.java --- a/Experiment.java Tue Nov 13 18:00:31 2012 +0000 +++ b/Experiment.java Tue Nov 13 23:57:14 2012 +0000 @@ -113,9 +113,9 @@ showClock = false; else showClock = true; - clockUnits = cu; - numUnits = nu; - scaleLength = sl; + clockUnits = positiveInteger(cu, 1); + numUnits = positiveInteger(nu, 4); + scaleLength = positiveInteger(sl, 7); midiDevice = md; lowAnchor = la; highAnchor = ha; @@ -244,4 +244,11 @@ } } + private int positiveInteger(int x, int def) { + if (x > 0) + return x; + else + return def; + } + }