Skip to content

Conversation

var-const
Copy link
Contributor

The root of the issue is that when serializing a singular filter, it is being treated as a unary filter before it is definitively established whether it is a unary filter or a field filter. The leak is caused by always serializing the unary filter's field path field for equality and non-equality filters -- if the filter's value turns out not to be NaN or null, the serialization code switches the filter's type to a field filter without clearing the partially-initialized unary filter. pb_release would not free the unary_filter.field.field_path member variable because it would consider the object not to be a unary filter.

Also a small refactoring to make the function easier to digest.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@var-const
Copy link
Contributor Author

@thebrianchen Brian, notifying you just to keep you in the loop.

@var-const var-const merged commit aee16f0 into master Oct 19, 2020
@morganchen12 morganchen12 deleted the varconst/fix-leak branch October 19, 2020 22:57
@morganchen12 morganchen12 added this to the 7.1.0 - M83 milestone Oct 19, 2020
paulb777 pushed a commit that referenced this pull request Oct 20, 2020
The root of the issue is that when serializing a singular filter, it is being treated as a unary filter before it is definitively established whether it is a unary filter or a field filter. The leak is caused by always serializing the unary filter's field path field for equality and non-equality filters -- if the filter's value turns out not to be NaN or null, the serialization code switches the filter's type to a field filter without clearing the partially-initialized unary filter. `pb_release` would not free the `unary_filter.field.field_path` member variable because it would consider the object not to be a unary filter.

Also a small refactoring to make the function easier to digest.
paulb777 pushed a commit that referenced this pull request Oct 20, 2020
The root of the issue is that when serializing a singular filter, it is being treated as a unary filter before it is definitively established whether it is a unary filter or a field filter. The leak is caused by always serializing the unary filter's field path field for equality and non-equality filters -- if the filter's value turns out not to be NaN or null, the serialization code switches the filter's type to a field filter without clearing the partially-initialized unary filter. `pb_release` would not free the `unary_filter.field.field_path` member variable because it would consider the object not to be a unary filter.

Also a small refactoring to make the function easier to digest.
paulb777 added a commit that referenced this pull request Oct 20, 2020
The root of the issue is that when serializing a singular filter, it is being treated as a unary filter before it is definitively established whether it is a unary filter or a field filter. The leak is caused by always serializing the unary filter's field path field for equality and non-equality filters -- if the filter's value turns out not to be NaN or null, the serialization code switches the filter's type to a field filter without clearing the partially-initialized unary filter. `pb_release` would not free the `unary_filter.field.field_path` member variable because it would consider the object not to be a unary filter.

Also a small refactoring to make the function easier to digest.

Co-authored-by: Konstantin Varlamov <[email protected]>