-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix oom #2665
Fix oom #2665
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.IO.Json; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Neo.UnitTests.IO.Json | ||
{ | ||
|
@@ -54,6 +55,13 @@ public class UT_JPath | |
["data"] = null, | ||
}; | ||
|
||
[TestMethod] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a boundary test where the size of an intermediate array is approximately equal to the maximum allowed limit? The size in case is This will help to ensure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad, the second test shouldn't pass because of the depth limit. |
||
public void TestOOM() | ||
{ | ||
var filter = "$" + string.Concat(Enumerable.Repeat("[0" + string.Concat(Enumerable.Repeat(",0", 64)) + "]", 6)); | ||
Assert.ThrowsException<InvalidOperationException>(() => JObject.Parse("[[[[[[{}]]]]]]").JsonPath(filter)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestJsonPath() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to make the exception more precise, use
ArgumentOutOfRangeException
orOutOfMemoryException
instead.