bug 645565 don't stomp previous 200 response with an invalid one, r=biesi, a=clegnitto
authorDaniel Veditz <dveditz@cruzio.com>
Mon, 11 Apr 2011 23:46:19 -0700
changeset 63414 fe85a4b7e1caa7bf221ba2c5ec40041504896237
parent 63413 f121cb9bad9efbcb48510eccba2e2c78f408d12a
child 63415 fd7e71967cfbfb50d4e60e736d0bd2dbc944ae3b
push id61
push userdveditz@mozilla.com
push dateTue, 12 Apr 2011 07:56:50 +0000
reviewersbiesi, clegnitto
bugs645565
milestone2.0.1pre
bug 645565 don't stomp previous 200 response with an invalid one, r=biesi, a=clegnitto
netwerk/streamconv/converters/nsDirIndexParser.cpp
--- a/netwerk/streamconv/converters/nsDirIndexParser.cpp
+++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp
@@ -174,18 +174,16 @@ nsDirIndexParser::gFieldTable[] = {
 nsrefcnt nsDirIndexParser::gRefCntParser = 0;
 nsITextToSubURI *nsDirIndexParser::gTextToSubURI;
 
 nsresult
 nsDirIndexParser::ParseFormat(const char* aFormatStr) {
   // Parse a "200" format line, and remember the fields and their
   // ordering in mFormat. Multiple 200 lines stomp on each other.
 
-  delete[] mFormat;
-
   // Lets find out how many elements we have.
   // easier to do this then realloc
   const char* pos = aFormatStr;
   unsigned int num = 0;
   do {
     while (*pos && nsCRT::IsAsciiSpace(PRUnichar(*pos)))
       ++pos;
     
@@ -198,16 +196,17 @@ nsDirIndexParser::ParseFormat(const char
     if (! *pos)
       break;
 
     while (*pos && !nsCRT::IsAsciiSpace(PRUnichar(*pos)))
       ++pos;
 
   } while (*pos);
 
+  delete[] mFormat;
   mFormat = new int[num+1];
   // Prevent NULL Deref - Bug 443299 
   if (mFormat == nsnull)
     return NS_ERROR_OUT_OF_MEMORY;
   mFormat[num] = -1;
   
   int formatNum=0;
   do {