-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
ojson jmespath::search()
heap use after free
#471
Comments
I am sure that this is not the correct fix, but the following removes the segfault by forcing jsoncons/include master$ git diff
diff --git a/include/jsoncons_ext/jmespath/jmespath.hpp b/include/jsoncons_ext/jmespath/jmespath.hpp
index a091085b6..25931632c 100644
--- a/include/jsoncons_ext/jmespath/jmespath.hpp
+++ b/include/jsoncons_ext/jmespath/jmespath.hpp
@@ -3376,8 +3376,10 @@ namespace jmespath {
{
return Json::null();
}
- dynamic_resources<Json,JsonReference> dynamic_storage;
- return deep_copy(*evaluate_tokens(doc, output_stack_, dynamic_storage, ec));
+ dynamic_resources<Json,JsonReference>* dynamic_storage = new dynamic_resources<Json,JsonReference>();
+ Json copy = deep_copy(*evaluate_tokens(doc, output_stack_, *dynamic_storage, ec));
+ free(dynamic_storage);
+ return copy;
}
static jmespath_expression compile(const string_view_type& expr) |
I'll have to study this a bit more, but could you also try
which should have the same affect? Thanks, |
That variant does not help. Actually, I used the following, without a
|
Okay, I think if you changed
to
in your variant, you'd see the same result as with my variant. That shouldn't happen, I'll need to investigate. |
yes, changing |
Could you check if you still see the segfault with the code on master? |
Success! |
Good. I think this is just another case of an over eager sanitizer. The "fix" was a work around that had no implications for heap memory access. |
Describe the bug
This program queries a JSON document with JMESPath, using the 'ojson' type
Compiling with 'address sanitizer'
indicates a memory access violation
What compiler, architecture, and operating system?
What jsoncons library version?
The text was updated successfully, but these errors were encountered: