Skip to content

Commit 7744eb8

Browse files
committed
Залечено NRE в конструкторах про которые известно. closes #1197
1 parent 5c04b92 commit 7744eb8

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/ScriptEngine.HostedScript/Library/FixedStructureImpl.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ private static FixedStructureImpl Constructor(StructureImpl structObject)
153153
[ScriptConstructor(Name = "По ключам и значениям")]
154154
public static FixedStructureImpl Constructor(IValue param1, IValue[] args)
155155
{
156-
var rawArgument = param1.GetRawValue();
156+
var rawArgument = param1?.GetRawValue();
157+
if (rawArgument == null)
158+
return new FixedStructureImpl("");
159+
157160
if (rawArgument.DataType == DataType.String)
158161
{
159162
return new FixedStructureImpl(param1.AsString(), args);

src/ScriptEngine.HostedScript/Library/StructureImpl.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ private static StructureImpl Constructor(FixedStructureImpl fixedStruct)
245245
[ScriptConstructor(Name = "По ключам и значениям")]
246246
public static StructureImpl Constructor(IValue param1, IValue[] args)
247247
{
248-
var rawArgument = param1.GetRawValue();
248+
var rawArgument = param1?.GetRawValue();
249+
if (rawArgument == null)
250+
return new StructureImpl();
251+
249252
if (rawArgument.DataType == DataType.String)
250253
{
251254
return new StructureImpl(rawArgument.AsString(), args);

src/ScriptEngine.HostedScript/Library/Zip/ZipReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void Open(IValue filenameOrStream, string password = null, FileNamesEncod
5454
{
5555
_zip = ZipFile.Read(filenameOrStream.AsString(), new ReadOptions { Encoding = ChooseEncoding(encoding) });
5656
}
57-
else if (filenameOrStream.AsObject() is IStreamWrapper stream)
57+
else if (filenameOrStream.DataType == DataType.Object && filenameOrStream.AsObject() is IStreamWrapper stream)
5858
{
5959
_zip = ZipFile.Read(stream.GetUnderlyingStream(), new ReadOptions { Encoding = ChooseEncoding(encoding) });
6060
}
@@ -157,7 +157,7 @@ public static ZipReader Construct()
157157
[ScriptConstructor(Name = "На основании имени файла или потока")]
158158
public static ZipReader Constructor(IValue dataSource, IValue password = null)
159159
{
160-
var dataSourceRawValue = dataSource.GetRawValue();
160+
var dataSourceRawValue = dataSource?.GetRawValue() ?? ValueFactory.CreateInvalidValueMarker();
161161

162162
return new ZipReader(dataSourceRawValue, password?.AsString());
163163
}

0 commit comments

Comments
 (0)