WSDG: Update docbook info
[metze/wireshark/wip.git] / epan / tvbuff_composite.c
index f43628b96a65e105a7a72264372b2db4983514e9..5832477f816211d8d2e6a8243ee57c8d7d08ec25 100644 (file)
@@ -6,19 +6,7 @@
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include "config.h"
@@ -112,8 +100,10 @@ composite_get_ptr(tvbuff_t *tvb, guint abs_offset, guint abs_length)
                return tvb_get_ptr(member_tvb, member_offset, abs_length);
        }
        else {
-               tvb->real_data = (guint8 *)g_malloc(abs_length);
-               tvb_memcpy(tvb, (void *)tvb->real_data, 0, abs_length);
+               /* Use a temporary variable as tvb_memcpy is also checking tvb->real_data pointer */
+               void *real_data = g_malloc(tvb->length);
+               tvb_memcpy(tvb, real_data, 0, tvb->length);
+               tvb->real_data = (const guint8 *)real_data;
                return tvb->real_data + abs_offset;
        }
 
@@ -296,6 +286,7 @@ tvb_composite_finalize(tvbuff_t *tvb)
 
        tvb_add_to_chain((tvbuff_t *)composite->tvbs->data, tvb); /* chain composite tvb to first member */
        tvb->initialized = TRUE;
+       tvb->ds_tvb = tvb;
 }
 
 /*