Frameworks/base: Fix more aapt issues

Change-Id: I6da7dc674e9f9e3b0886a3cfd1e3194d6b5ac948
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index d8e2de6..c262b00 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -192,7 +192,7 @@
 
 void AaptLocaleValue::setLanguage(const char* languageChars) {
      size_t i = 0;
-     while ((*languageChars) != '\0') {
+     while ((*languageChars) != '\0' && i < sizeof(language)/sizeof(language[0])) {
           language[i++] = tolower(*languageChars);
           languageChars++;
      }
@@ -200,7 +200,7 @@
 
 void AaptLocaleValue::setRegion(const char* regionChars) {
     size_t i = 0;
-    while ((*regionChars) != '\0') {
+    while ((*regionChars) != '\0' && i < sizeof(region)/sizeof(region[0])) {
          region[i++] = toupper(*regionChars);
          regionChars++;
     }
@@ -208,7 +208,7 @@
 
 void AaptLocaleValue::setScript(const char* scriptChars) {
     size_t i = 0;
-    while ((*scriptChars) != '\0') {
+    while ((*scriptChars) != '\0' && i < sizeof(script)/sizeof(script[0])) {
          if (i == 0) {
              script[i++] = toupper(*scriptChars);
          } else {
@@ -220,7 +220,7 @@
 
 void AaptLocaleValue::setVariant(const char* variantChars) {
      size_t i = 0;
-     while ((*variantChars) != '\0') {
+     while ((*variantChars) != '\0' && i < sizeof(variant)/sizeof(variant[0])) {
           variant[i++] = *variantChars;
           variantChars++;
      }