yiguolei commented on code in PR #33622:
URL: https://github.com/apache/doris/pull/33622#discussion_r1564072517


##########
be/src/util/block_compression.cpp:
##########
@@ -382,6 +382,7 @@ class Lz4fBlockCompression : public BlockCompressionCodec {
             }
             auto res = LZ4F_createCompressionContext(&context->ctx, 
LZ4F_VERSION);
             if (LZ4F_isError(res) != 0) {
+                delete context;

Review Comment:
   We could not depend on delete to release memory, the developer may forget to 
do it. For example, if any other developer add some return code at 388 or 389, 
he or she has to call delete context again.
    Maybe we could change code like this:
   1. std::unique_ptr<CContext> context = std::make_unique<CContext>();
   2. *out = context.release();
   The code will be more robust to avoid forgetting to delete the object.
   
   And also you coud add ENABLE_FACTORY_CREATOR macro to class CContext. It 
will forbid developer call NEW to create object directly.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to