aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netmon.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-01 06:48:37 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-01 06:48:37 +0000
commit6b4c30b69da69f2f8680e50d9790740567d9310f (patch)
tree500b9e74190706e81ad4628a722ca51e42fe137f /wiretap/netmon.c
parent7658263b0ed2f64f9b03dcc25a7669f3decfe6d5 (diff)
When allocating the frame table for a NetMon file, use g_try_malloc(),
and fail with ENOMEM if that fails (and the frame table is not empty - g_try_malloc() will return NULL if you ask it to allocate zero bytes). Have an error message for ENOMEM on an open that attempts to tell the user what the problem is without making their head explode. svn path=/trunk/; revision=49673
Diffstat (limited to 'wiretap/netmon.c')
-rw-r--r--wiretap/netmon.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index aa97cf6195..9f5d1b5578 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -359,7 +359,11 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
return -1;
}
- frame_table = (guint32 *)g_malloc(frame_table_length);
+ frame_table = (guint32 *)g_try_malloc(frame_table_length);
+ if (frame_table_length != 0 && frame_table == NULL) {
+ *err = ENOMEM; /* we assume we're out of memory */
+ return -1;
+ }
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(frame_table, frame_table_length, wth->fh);
if ((guint32)bytes_read != frame_table_length) {