You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/06/11 10:54:19 UTC
[GitHub] [incubator-doris] vagetablechicken opened a new issue #3843: [UDF] StringVal::operator==() should avoid pass NULL to memcmp()
vagetablechicken opened a new issue #3843:
URL: https://github.com/apache/incubator-doris/issues/3843
**Describe the bug**
A clear and concise description of what the bug is.
https://github.com/apache/incubator-doris/blob/e16873a6c1bbf0cf9e97f7a7bfd60b162eea4e31/be/src/udf/udf.h#L634-L648
StringVal::operator==() will check `is_null`, `len` & content(`*ptr`).
But when a StringVal obj `sval` len==0, the ptr can be NULL. It's possible to pass NULL ptr to memcmp(). Ref https://en.cppreference.com/w/c/string/byte/memcmp, The behavior is undefined if either lhs or rhs is a null pointer.
It's better to fix it.
```
StringVal StringFunctions::substring(
FunctionContext* context, const StringVal& str,
const IntVal& pos, const IntVal& len)
```
`StringFunctions::substring()` will return `StringVal()` when arg len == 0, StringVal() will set ptr to NULL, len to 0.
If we don't want to give a `len == 0` StringVal an empty string('\0'), we should skip memcmp() when lhs or rhs `len == 0`.
**To Reproduce**
Steps to reproduce the behavior:
1. compare `StringVal(len=0, ptr="")` with `StringVal()`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] vagetablechicken closed issue #3843: [UDF] StringVal::operator==() should avoid pass NULL to memcmp()
Posted by GitBox <gi...@apache.org>.
vagetablechicken closed issue #3843:
URL: https://github.com/apache/incubator-doris/issues/3843
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org