From f3e7a406163e8bf7342e3e40d3881905725005dc Mon Sep 17 00:00:00 2001 From: BT Templeton Date: Thu, 28 Jun 2012 00:01:20 -0400 Subject: use xmalloc in x_get_window_property * src/alloc.c (x_get_window_property): Use `xmalloc'. --- src/xselect.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/xselect.c') diff --git a/src/xselect.c b/src/xselect.c index 89ec1da30b..93de0f5f9d 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1299,9 +1299,7 @@ x_get_window_property (Display *display, Window window, Atom property, if (total_size_max < bytes_remaining) goto size_overflow; total_size = bytes_remaining; - data = malloc (total_size + 1); - if (! data) - goto memory_exhausted; + data = xmalloc (total_size + 1); /* Now read, until we've gotten it all. */ while (bytes_remaining) @@ -1347,15 +1345,11 @@ x_get_window_property (Display *display, Window window, Atom property, if (total_size - offset < bytes_gotten) { - unsigned char *data1; ptrdiff_t remaining_lim = total_size_max - offset - bytes_gotten; if (remaining_lim < 0 || remaining_lim < bytes_remaining) goto size_overflow; total_size = offset + bytes_gotten + bytes_remaining; - data1 = realloc (data, total_size + 1); - if (! data1) - goto memory_exhausted; - data = data1; + data = xrealloc (data, total_size + 1); } if (BITS_PER_LONG > 32 && *actual_format_ret == 32) @@ -1386,14 +1380,9 @@ x_get_window_property (Display *display, Window window, Atom property, return; size_overflow: - free (data); + xfree (data); unblock_input (); memory_full (SIZE_MAX); - - memory_exhausted: - free (data); - unblock_input (); - memory_full (total_size + 1); } /* Use xfree, not XFree, to free the data obtained with this function. */ -- cgit v1.2.3