summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Yuan Huang2016-11-15 18:13:42 -0600
committerTing-Yuan Huang2016-11-22 17:33:34 -0600
commit1c2f612c18225719719e68d819625e2f8741881a (patch)
tree8571faee61a7357090f2ea84643e854fa4677fa6 /toolbox
parent72662414f628b695d37700999532d27c1baa044f (diff)
downloadplatform-system-core-1c2f612c18225719719e68d819625e2f8741881a.tar.gz
platform-system-core-1c2f612c18225719719e68d819625e2f8741881a.tar.xz
platform-system-core-1c2f612c18225719719e68d819625e2f8741881a.zip
toolbox: exit when failed to allocate buffer for ioctl
This is a "shouldn't happen" case. Test: make WITH_TIDY=1 mmma system/core/toolbox Change-Id: I51e44e17837b03d6df6f8c4c3e1aeab8253e094d
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/getevent.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/toolbox/getevent.c b/toolbox/getevent.c
index 30053af80..e6def6bae 100644
--- a/toolbox/getevent.c
+++ b/toolbox/getevent.c
@@ -9,6 +9,7 @@
9#include <sys/limits.h> 9#include <sys/limits.h>
10#include <sys/poll.h> 10#include <sys/poll.h>
11#include <linux/input.h> 11#include <linux/input.h>
12#include <err.h>
12#include <errno.h> 13#include <errno.h>
13#include <unistd.h> 14#include <unistd.h>
14 15
@@ -110,10 +111,8 @@ static int print_possible_events(int fd, int print_flags)
110 break; 111 break;
111 bits_size = res + 16; 112 bits_size = res + 16;
112 bits = realloc(bits, bits_size * 2); 113 bits = realloc(bits, bits_size * 2);
113 if(bits == NULL) { 114 if(bits == NULL)
114 fprintf(stderr, "failed to allocate buffer of size %d\n", (int)bits_size); 115 err(1, "failed to allocate buffer of size %d\n", (int)bits_size);
115 return 1;
116 }
117 } 116 }
118 res2 = 0; 117 res2 = 0;
119 switch(i) { 118 switch(i) {