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"}
|
||||
(fn [stack state]
|
||||
(make-instruction state
|
||||
#(try ((if (= stack :integer) int float) (read-string %))
|
||||
#?(:clj (catch Exception e)
|
||||
:cljs (catch js/Error. e)))
|
||||
#(try (if (= stack :integer)
|
||||
#?(:clj (Integer/parseInt %)
|
||||
:cljs (js/parseInt %))
|
||||
#?(:clj (Float/parseFloat %)
|
||||
:cljs (js/parseFloat %)))
|
||||
#?(:clj (catch Exception e :ignore-instruction)
|
||||
:cljs (catch js/Error e :ignore-instruction)))
|
||||
[:string]
|
||||
stack)))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user