浏览代码

[eval] don't throw upon casting (null:String) to NativeString

Aleksandr Kuzmenko 4 年之前
父节点
当前提交
7595ca2a1a
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 1 0
      extra/CHANGES.txt
  2. 3 2
      src/macro/eval/evalStdLib.ml

+ 1 - 0
extra/CHANGES.txt

@@ -12,6 +12,7 @@
 	jvm : fixed manifest generation for cases with a lot of jar libraries (#10157)
 	js : fixed extending extern classes for es5 (#10192)
 	js : fixed checking `this` before `super` for es6 (#10193)
+	eval : fixed null pointer exception in `eval.NativeString.fromString(null)`
 
 2021-02-26 4.2.1:
 

+ 3 - 2
src/macro/eval/evalStdLib.ml

@@ -3075,8 +3075,9 @@ end
 
 module StdNativeString = struct
 	let from_string = vfun1 (fun v ->
-		let s = decode_vstring v in
-		vnative_string s.sstring
+		match decode_optional decode_vstring v with
+		| None -> vnull
+		| Some s -> vnative_string s.sstring
 	)
 
 	let from_bytes = vfun1 (fun v ->