diff options
author | BT Templeton <[email protected]> | 2012-06-28 00:01:20 -0400 |
---|---|---|
committer | Robin Templeton <[email protected]> | 2015-02-09 13:04:17 -0500 |
commit | f3e7a406163e8bf7342e3e40d3881905725005dc (patch) | |
tree | 094db75e7be154e1bb7f1cc9e27a0a26bf1637c1 /src/xselect.c | |
parent | c6b04f6bef2a4e1e6073263488151bd76cd88bc5 (diff) |
use xmalloc in x_get_window_property
* src/alloc.c (x_get_window_property): Use `xmalloc'.
Diffstat (limited to 'src/xselect.c')
-rw-r--r-- | src/xselect.c | 17 |
1 files changed, 3 insertions, 14 deletions
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. */ |