From 2d1afe61df36ed1682b523af2e0fb58e8da966e7 Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Fri, 15 Jun 2001 00:37:14 +0000 Subject: [PATCH] Fix for 84332 -- made string dynamic vs hardcoded size, r=peterl, sr=rpotts, a=blizzard git-svn-id: svn://10.0.0.236/trunk@97188 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/nsPluginHostImpl.cpp | 27 +++++++------------ .../plugin/nglsrc/nsPluginHostImpl.cpp | 27 +++++++------------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index a5679cdf909..bcdbfc7b97c 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1090,11 +1090,7 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq return; PRInt32 requestCnt = 0; - // XXX needs to be smarter than that - char * string = new char[1024]; - - string[0] = '\0'; - PL_strcat(string, "bytes="); + nsCAutoString string("bytes="); for(nsByteRange * range = aRangeList; range != nsnull; range = range->next) { @@ -1103,24 +1099,19 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq continue; // XXX needs to be fixed for negative offsets - nsCString firstbyte; firstbyte.AppendInt(range->offset); - nsCString lastbyte; lastbyte.AppendInt(range->offset + range->length - 1); - - PL_strcat(string, firstbyte.get()); - PL_strcat(string, "-"); - PL_strcat(string, lastbyte.get()); + string.AppendInt(range->offset); + string.Append("-"); + string.AppendInt(range->offset + range->length - 1); if(range->next) - PL_strcat(string, ","); + string += ","; requestCnt++; } - // get rid of possible tailing comma - PRInt32 len = PL_strlen(string); - if(string[len - 1] == ',') - string[len - 1] = '\0'; + // get rid of possible trailing comma + string.Trim(",", PR_FALSE); - *rangeRequest = string; + *rangeRequest = string.ToNewCString(); *numRequests = requestCnt; return; } @@ -1154,7 +1145,7 @@ nsPluginStreamInfo::RequestRead(nsByteRange* rangeList) httpChannel->SetRequestHeader("Range", rangeString); - delete [] rangeString; + nsMemory::Free(rangeString); // instruct old stream listener to cancel the request on the next // attempt to write. diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index a5679cdf909..bcdbfc7b97c 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -1090,11 +1090,7 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq return; PRInt32 requestCnt = 0; - // XXX needs to be smarter than that - char * string = new char[1024]; - - string[0] = '\0'; - PL_strcat(string, "bytes="); + nsCAutoString string("bytes="); for(nsByteRange * range = aRangeList; range != nsnull; range = range->next) { @@ -1103,24 +1099,19 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq continue; // XXX needs to be fixed for negative offsets - nsCString firstbyte; firstbyte.AppendInt(range->offset); - nsCString lastbyte; lastbyte.AppendInt(range->offset + range->length - 1); - - PL_strcat(string, firstbyte.get()); - PL_strcat(string, "-"); - PL_strcat(string, lastbyte.get()); + string.AppendInt(range->offset); + string.Append("-"); + string.AppendInt(range->offset + range->length - 1); if(range->next) - PL_strcat(string, ","); + string += ","; requestCnt++; } - // get rid of possible tailing comma - PRInt32 len = PL_strlen(string); - if(string[len - 1] == ',') - string[len - 1] = '\0'; + // get rid of possible trailing comma + string.Trim(",", PR_FALSE); - *rangeRequest = string; + *rangeRequest = string.ToNewCString(); *numRequests = requestCnt; return; } @@ -1154,7 +1145,7 @@ nsPluginStreamInfo::RequestRead(nsByteRange* rangeList) httpChannel->SetRequestHeader("Range", rangeString); - delete [] rangeString; + nsMemory::Free(rangeString); // instruct old stream listener to cancel the request on the next // attempt to write.