summaryrefslogtreecommitdiffstats
path: root/adb/commandline.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-22 20:05:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-22 20:05:46 +0000
commit876881b22ad5d735cdb3ae2ac1afa6c336378808 (patch)
tree96e6fe53791cd8c57dc6bf4153773e55a0d7cc8c /adb/commandline.cpp
parentf75f16a1ddbe6cde5e44036d48dc7a6c62d38cc0 (diff)
parentdc3b459ff9f0ff71d404ba7198083e532a0dd894 (diff)
downloadsystem_core-876881b22ad5d735cdb3ae2ac1afa6c336378808.tar.gz
system_core-876881b22ad5d735cdb3ae2ac1afa6c336378808.tar.bz2
system_core-876881b22ad5d735cdb3ae2ac1afa6c336378808.zip
Merge "Add missing null checks after allocations."
Diffstat (limited to 'adb/commandline.cpp')
-rw-r--r--adb/commandline.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index e76c34119..e59a96a8f 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -312,6 +312,7 @@ static void read_status_line(int fd, char* buf, size_t count)
static void copy_to_file(int inFd, int outFd) {
const size_t BUFSIZE = 32 * 1024;
char* buf = (char*) malloc(BUFSIZE);
+ if (buf == nullptr) fatal("couldn't allocate buffer for copy_to_file");
int len;
long total = 0;
@@ -419,6 +420,11 @@ static int interactive_shell() {
fdi = 0; //dup(0);
int* fds = reinterpret_cast<int*>(malloc(sizeof(int) * 2));
+ if (fds == nullptr) {
+ fprintf(stderr, "couldn't allocate fds array: %s\n", strerror(errno));
+ return 1;
+ }
+
fds[0] = fd;
fds[1] = fdi;