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 23:15:23 +00:00
Родитель 4f10d56fb7
Коммит 1d7f2896ea
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -336,10 +336,12 @@ nsPNGEncoder::ParseOptions(const nsAString& aOptions,
PRUint32* offsetX,
PRUint32* offsetY)
{
char* token;
char* options = nsCRT::strdup(PromiseFlatCString(NS_ConvertUTF16toUTF8(aOptions)).get());
// Make a copy of aOptions, because strtok() will modify it.
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.
char* equals = token, *value = nsnull;
while(*equals != '=' && *equals) { ++equals; }