Fix the _from_string
instruction
This replaces the dangerous use of `read-string`with `parseInt` and `parseFloat`, and returns `ignore-instruction` if an exception is thrown when trying to do the parsing. Hopefully this will fix the stack overflow problems with the PSB2 Middle Character and Twitter problems.
This commit is contained in:
parent
7681f54013
commit
6b454451d7
@ -121,9 +121,13 @@
|
|||||||
:name "_from_string"}
|
:name "_from_string"}
|
||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state
|
(make-instruction state
|
||||||
#(try ((if (= stack :integer) int float) (read-string %))
|
#(try (if (= stack :integer)
|
||||||
#?(:clj (catch Exception e)
|
#?(:clj (Integer/parseInt %)
|
||||||
:cljs (catch js/Error. e)))
|
:cljs (js/parseInt %))
|
||||||
|
#?(:clj (Float/parseFloat %)
|
||||||
|
:cljs (js/parseFloat %)))
|
||||||
|
#?(:clj (catch Exception e :ignore-instruction)
|
||||||
|
:cljs (catch js/Error e :ignore-instruction)))
|
||||||
[:string]
|
[:string]
|
||||||
stack)))
|
stack)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user