Merge branch 'mainstream'
[sliver-openvswitch.git] / lib / ofp-util.c
index b181a0d..8ac9186 100644 (file)
@@ -5480,7 +5480,8 @@ ofputil_decode_group_stats_request(const struct ofp_header *request,
 }
 
 /* Converts a group stats reply in 'msg' into an abstract ofputil_group_stats
- * in 'gs'.
+ * in 'gs'.  Assigns freshly allocated memory to gs->bucket_stats for the
+ * caller to eventually free.
  *
  * Multiple group stats replies can be packed into a single OpenFlow message.
  * Calling this function multiple times for a single 'msg' iterates through the
@@ -5501,6 +5502,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
     size_t length;
     size_t i;
 
+    gs->bucket_stats = NULL;
     error = (msg->l2
              ? ofpraw_decode(&raw, msg->l2)
              : ofpraw_pull(&raw, msg));
@@ -5557,6 +5559,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
+    gs->bucket_stats = xmalloc(gs->n_buckets * sizeof *gs->bucket_stats);
     for (i = 0; i < gs->n_buckets; i++) {
         gs->bucket_stats[i].packet_count = ntohll(obc[i].packet_count);
         gs->bucket_stats[i].byte_count = ntohll(obc[i].byte_count);