bneradt commented on code in PR #12333:
URL: https://github.com/apache/trafficserver/pull/12333#discussion_r2183900407


##########
plugins/stats_over_http/stats_over_http.cc:
##########
@@ -120,33 +120,49 @@ static bool             is_ipmap_allowed(const config_t 
*config, const struct so
 
 #if HAVE_BROTLI_ENCODE_H
 struct b_stream {
-  BrotliEncoderState *br;
-  uint8_t            *next_in;
-  size_t              avail_in;
-  uint8_t            *next_out;
-  size_t              avail_out;
-  size_t              total_in;
-  size_t              total_out;
+  BrotliEncoderState *br        = nullptr;
+  uint8_t            *next_in   = nullptr;
+  size_t              avail_in  = 0;
+  uint8_t            *next_out  = nullptr;
+  size_t              avail_out = 0;
+  size_t              total_in  = 0;
+  size_t              total_out = 0;
+
+  ~b_stream()
+  {
+    if (br) {
+      BrotliEncoderDestroyInstance(br);
+      br = nullptr;
+    }

Review Comment:
   This is the real fix. 
   
   However, with a destructor, b_stream is no longer a POD, so the memset in 
`stats_origin` no longer works and rightfully causes a compiler warning. So the 
rest of this patch is so that new of `stats_stat` 0-initializes the content.



-- 
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: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to