diff options
author | Elliott Hughes <enh@google.com> | 2015-04-21 19:39:52 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-04-21 19:43:22 -0700 |
commit | dc3b459ff9f0ff71d404ba7198083e532a0dd894 (patch) | |
tree | 3e64efa2fefb22f72fbeb303a672353fb219de16 /adb/usb_linux_client.cpp | |
parent | 9a0cea92c8b74114b70ac3339b2b611633f6a31a (diff) | |
download | system_core-dc3b459ff9f0ff71d404ba7198083e532a0dd894.zip system_core-dc3b459ff9f0ff71d404ba7198083e532a0dd894.tar.gz system_core-dc3b459ff9f0ff71d404ba7198083e532a0dd894.tar.bz2 |
Add missing null checks after allocations.
Bug: http://b/20317729
Change-Id: I62bb761d48ee59a1f4ddd0cdd0632432305ca2ca
Diffstat (limited to 'adb/usb_linux_client.cpp')
-rw-r--r-- | adb/usb_linux_client.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/adb/usb_linux_client.cpp b/adb/usb_linux_client.cpp index 6d21104..18289e2 100644 --- a/adb/usb_linux_client.cpp +++ b/adb/usb_linux_client.cpp @@ -241,6 +241,8 @@ static void usb_adb_kick(usb_handle *h) static void usb_adb_init() { usb_handle* h = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle))); + if (h == nullptr) fatal("couldn't allocate usb_handle"); + h->write = usb_adb_write; h->read = usb_adb_read; h->kick = usb_adb_kick; @@ -468,6 +470,8 @@ static void usb_ffs_init() D("[ usb_init - using FunctionFS ]\n"); usb_handle* h = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle))); + if (h == nullptr) fatal("couldn't allocate usb_handle"); + h->write = usb_ffs_write; h->read = usb_ffs_read; h->kick = usb_ffs_kick; |