Skip to content
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

thrift : fix list<bool> #382

Merged
merged 2 commits into from
May 21, 2024
Merged

thrift : fix list<bool> #382

merged 2 commits into from
May 21, 2024

Conversation

holmes1412
Copy link
Contributor

@holmes1412 holmes1412 requested a review from kedixa May 21, 2024 11:07
@Barenboim Barenboim linked an issue May 21, 2024 that may be closed by this pull request
if (!buffer->readI32(count))
return false;

list->resize(count);
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是否容易被OOM攻击

Copy link
Contributor

Choose a reason for hiding this comment

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

这个要改的就多了。以后再说吧。

Comment on lines +221 to +227
for (size_t i = 0; i < list->size(); ++i)
{
bool ele;
if (!val_desc->reader(buffer, &ele))
return false;
(*list)[i] = ele;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

对于这个场景(由于要求使用C++ 11标准),如果想避免特化class ThriftDescriptorImpl<std::vector<bool>, TDT_LIST, void, VALIMPL>这个很长的类,并且对val_desc的特化的代码更方便,可以将这部分内容实现为

using vector_value_ref = typename T::reference;
for (vector_value_ref ele : *list)
{
    // do something with ele
}

并对val_desc模板参数std::vector<bool>::reference类型进行特化。注意,这个坏坏的std::vector<bool>::reference看起来是引用,其实它是一个值类型。

@kedixa
Copy link
Contributor

kedixa commented May 21, 2024

intv *= 10;
intv += base[i] - '0';

对于输入为LONG_MIN,这里有个有符号数上溢

@Barenboim Barenboim merged commit 6996fb8 into sogou:master May 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

list<bool>和map返回值不能正确处理
3 participants