Bug 1125592 - Fix -Wmaybe-uninitialized warning in security/manager/ssl/src/nsNSSASN1Object.cpp. r=dkeeler
authorChris Peterson <cpeterson@mozilla.com>
Fri, 23 Jan 2015 22:58:43 -0800
changeset 239280 2b207b997e4cb0ec06339ac96a74d654b4a19bcf
parent 239279 cffc8f5b70681e412f5e26191b7ef84c3909e422
child 239281 8eec3d8ec60a928e55d90bb94a9430a36fc7e64f
push id497
push usermleibovic@mozilla.com
push dateWed, 28 Jan 2015 16:43:37 +0000
reviewersdkeeler
bugs1125592
milestone38.0a1
Bug 1125592 - Fix -Wmaybe-uninitialized warning in security/manager/ssl/src/nsNSSASN1Object.cpp. r=dkeeler
security/manager/ssl/src/nsNSSASN1Object.cpp
--- a/security/manager/ssl/src/nsNSSASN1Object.cpp
+++ b/security/manager/ssl/src/nsNSSASN1Object.cpp
@@ -121,21 +121,27 @@ buildASN1ObjectFromDER(unsigned char *da
     tagnum = code & SEC_ASN1_TAGNUM_MASK;
 
     /*
      * NOTE: This code does not (yet) handle the high-tag-number form!
      */
     if (tagnum == SEC_ASN1_HIGH_TAG_NUMBER) {
       return NS_ERROR_FAILURE;
     }
+
     data++;
     len = getDERItemLength(data, end, &bytesUsed, &indefinite);
+    if (len < 0) {
+      return NS_ERROR_FAILURE;
+    }
+
     data += bytesUsed;
-    if ((len < 0) || ((data+len) > end))
+    if (data + len > end) {
       return NS_ERROR_FAILURE;
+    }
 
     if (code & SEC_ASN1_CONSTRUCTED) {
       if (len > 0 || indefinite) {
         sequence = new nsNSSASN1Sequence();
         switch (code & SEC_ASN1_CLASS_MASK) {
         case SEC_ASN1_UNIVERSAL:
           type = tagnum;
           break;
@@ -313,17 +319,16 @@ nsNSSASN1Sequence::GetIsExpanded(bool *a
 
 NS_IMETHODIMP 
 nsNSSASN1Sequence::SetIsExpanded(bool aIsExpanded)
 {
   mIsExpanded = aIsExpanded;
   return NS_OK;
 }
 
-
 nsNSSASN1PrintableItem::nsNSSASN1PrintableItem() : mType(0),
                                                    mTag(0),
                                                    mData(nullptr),
                                                    mLen(0)
 {
   /* member initializers and constructor code */
 }
 
@@ -420,9 +425,8 @@ nsNSSASN1PrintableItem::GetDisplayName(n
 }
 
 NS_IMETHODIMP 
 nsNSSASN1PrintableItem::SetDisplayName(const nsAString &aDisplayName)
 {
   mDisplayName = aDisplayName;
   return NS_OK;
 }
-