Bug 413424 - PNG encoder leaks a string. r=stuart, a1.9=schrep, guilty=dolske

This commit is contained in:
dolske@mozilla.com 2008-01-22 15:15:23 -08:00
parent 40fe97dc61
commit aaac9bf4aa

View File

@ -336,10 +336,12 @@ nsPNGEncoder::ParseOptions(const nsAString& aOptions,
PRUint32* offsetX, PRUint32* offsetX,
PRUint32* offsetY) PRUint32* offsetY)
{ {
char* token; // Make a copy of aOptions, because strtok() will modify it.
char* options = nsCRT::strdup(PromiseFlatCString(NS_ConvertUTF16toUTF8(aOptions)).get()); nsCAutoString optionsCopy;
optionsCopy.Assign(NS_ConvertUTF16toUTF8(aOptions));
char* options = optionsCopy.BeginWriting();
while ((token = nsCRT::strtok(options, ";", &options))) { while (char* token = nsCRT::strtok(options, ";", &options)) {
// If there's an '=' character, split the token around it. // If there's an '=' character, split the token around it.
char* equals = token, *value = nsnull; char* equals = token, *value = nsnull;
while(*equals != '=' && *equals) { ++equals; } while(*equals != '=' && *equals) { ++equals; }