* 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>
guint bytes_in = tvb_captured_length_remaining(tvb, offset);
#endif
- if (tvb == NULL) {
+ if (tvb == NULL || comprlen <= 0) {
return NULL;
}
- compr = (guint8 *)g_malloc(comprlen);
- tvb_memcpy(tvb, compr, offset, comprlen);
-
- if (!compr)
+ compr = (guint8 *)tvb_memdup(NULL, tvb, offset, comprlen);
+ if (compr == NULL) {
return NULL;
+ }
/*
* Assume that the uncompressed data is at least twice as big as
if (err != Z_OK) {
inflateEnd(strm);
g_free(strm);
- g_free(compr);
+ wmem_free(NULL, compr);
g_free(strmbuf);
return NULL;
}
if (uncompr != NULL) {
break;
} else {
- g_free(compr);
+ wmem_free(NULL, compr);
return NULL;
}
if (comprlen < 10 || *c != Z_DEFLATED) {
inflateEnd(strm);
g_free(strm);
- g_free(compr);
+ wmem_free(NULL, compr);
g_free(strmbuf);
return NULL;
}
if (c - compr > comprlen) {
inflateEnd(strm);
g_free(strm);
- g_free(compr);
+ wmem_free(NULL, compr);
g_free(strmbuf);
return NULL;
}
if (err != Z_OK) {
g_free(strm);
g_free(strmbuf);
- g_free(compr);
+ wmem_free(NULL, compr);
g_free(uncompr);
return NULL;
g_free(strmbuf);
if (uncompr == NULL) {
- g_free(compr);
+ wmem_free(NULL, compr);
return NULL;
}
uncompr_tvb = tvb_new_real_data((guint8*) uncompr, bytes_out, bytes_out);
tvb_set_free_cb(uncompr_tvb, g_free);
}
- g_free(compr);
+ wmem_free(NULL, compr);
return uncompr_tvb;
}
#else