diff options
author | Pete Batard <pete@akeo.ie> | 2012-06-07 19:27:43 +0100 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2012-06-08 23:30:54 +0100 |
commit | a983fad006fe39a48517e061bf9f66501ff900be (patch) | |
tree | 7077240159f3ae43089f10f7ae642fb56930c88e /libusb/descriptor.c | |
parent | ff3259b440b3fa55a48cfb6233341c9ff664894a (diff) | |
download | libusb-a983fad006fe39a48517e061bf9f66501ff900be.tar.gz |
All: Prevent memory leaks on realloc failures
* p = realloc(p, new_size) does not free the original buffer in case of
a realloc failure.
* reallocf() can be used to do so, but is not available on all platforms.
* This patch introduces usbi_reallocf() in libusbi.h and use that instead of realloc
* Issue and original patch submitted by Moritz Lipp (trac #27)
Diffstat (limited to 'libusb/descriptor.c')
-rw-r--r-- | libusb/descriptor.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libusb/descriptor.c b/libusb/descriptor.c index 590d1dc..763f93c 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c @@ -198,7 +198,7 @@ static int parse_interface(libusb_context *ctx, while (size >= INTERFACE_DESC_LENGTH) { struct libusb_interface_descriptor *altsetting = (struct libusb_interface_descriptor *) usb_interface->altsetting; - altsetting = realloc(altsetting, + altsetting = usbi_reallocf(altsetting, sizeof(struct libusb_interface_descriptor) * (usb_interface->num_altsetting + 1)); if (!altsetting) { |