* 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"
-#include <epan/emem.h>
-
#include "tvbuff.h"
#include "tvbuff-int.h"
#include "proto.h" /* XXX - only used for DISSECTOR_ASSERT, probably a new header file? */
return tvb_get_ptr(member_tvb, member_offset, abs_length);
}
else {
- tvb->real_data = (guint8 *)tvb_memdup(NULL, tvb, 0, -1);
+ /* 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;
}
* then iterate across the other member tvb's, copying their portions
* until we have copied all data.
*/
- member_length = tvb_length_remaining(member_tvb, member_offset);
+ member_length = tvb_captured_length_remaining(member_tvb, member_offset);
/* composite_memcpy() can't handle a member_length of zero. */
DISSECTOR_ASSERT(member_length > 0);
composite->end_offsets[i] = tvb->length - 1;
i++;
}
+
+ DISSECTOR_ASSERT(composite->tvbs);
+
tvb_add_to_chain((tvbuff_t *)composite->tvbs->data, tvb); /* chain composite tvb to first member */
tvb->initialized = TRUE;
+ tvb->ds_tvb = tvb;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */