summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorAlexander Ivchenko <alexander.ivchenko@intel.com>2014-08-06 14:51:40 +0400
committerElliott Hughes <enh@google.com>2014-08-06 10:59:53 -0700
commit678bd2e8225ccebe678430d4095b7fc78253bcf8 (patch)
tree22a87361fbce8b668084adf473e599ce0b22df98 /adb
parent46a8ffe87f3cba070fb18a90e3c5c1f73468f99c (diff)
downloadsystem_core-678bd2e8225ccebe678430d4095b7fc78253bcf8.zip
system_core-678bd2e8225ccebe678430d4095b7fc78253bcf8.tar.gz
system_core-678bd2e8225ccebe678430d4095b7fc78253bcf8.tar.bz2
Fix build of adb with gcc-4.9.
Without this patch we get: system/core/adb/commandline.c:1629:16: error: array subscript is above array bounds [-Werror=array-bounds] Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com> (cherry picked from commit 53723338858772a0189aa3f92f4d4bbdaa9b6772) Change-Id: I920c1de933ce5ba0a0d57eb8a9b557325a767a2a
Diffstat (limited to 'adb')
-rw-r--r--adb/commandline.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/adb/commandline.c b/adb/commandline.c
index 2df3f09..b268ca5 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -1746,9 +1746,10 @@ top:
return 1;
}
+#define MAX_ARGV_LENGTH 16
static int do_cmd(transport_type ttype, char* serial, char *cmd, ...)
{
- char *argv[16];
+ char *argv[MAX_ARGV_LENGTH];
int argc;
va_list ap;
@@ -1765,7 +1766,9 @@ static int do_cmd(transport_type ttype, char* serial, char *cmd, ...)
}
argv[argc++] = cmd;
- while((argv[argc] = va_arg(ap, char*)) != 0) argc++;
+ while(argc < MAX_ARGV_LENGTH &&
+ (argv[argc] = va_arg(ap, char*)) != 0) argc++;
+ assert(argc < MAX_ARGV_LENGTH);
va_end(ap);
#if 0