Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: third_party/WebKit/Source/core/xml/XSLTProcessorLibxslt.cpp

Issue 2957933002: Fix another FastMalloc call site with potential integer overflow. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/wtf/allocator/Partitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the XSL implementation. 2 * This file is part of the XSL implementation.
3 * 3 *
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved.
5 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org> 5 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org>
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 length, WTF_HEAP_PROFILER_TYPE_NAME(XSLTProcessor))); 224 length, WTF_HEAP_PROFILER_TYPE_NAME(XSLTProcessor)));
225 memcpy(parameter_array, data, length); 225 memcpy(parameter_array, data, length);
226 return parameter_array; 226 return parameter_array;
227 } 227 }
228 228
229 static const char** XsltParamArrayFromParameterMap( 229 static const char** XsltParamArrayFromParameterMap(
230 XSLTProcessor::ParameterMap& parameters) { 230 XSLTProcessor::ParameterMap& parameters) {
231 if (parameters.IsEmpty()) 231 if (parameters.IsEmpty())
232 return nullptr; 232 return nullptr;
233 233
234 const char** parameter_array = static_cast<const char**>( 234 WTF::CheckedSizeT size = parameters.size();
Tom Sepez 2017/06/26 22:33:36 Blink is pretty slap-happy about using "unsigned"
235 WTF::Partitions::FastMalloc(((parameters.size() * 2) + 1) * sizeof(char*), 235 size *= 2;
236 WTF_HEAP_PROFILER_TYPE_NAME(XSLTProcessor))); 236 ++size;
237 size *= sizeof(char*);
238 const char** parameter_array =
239 static_cast<const char**>(WTF::Partitions::FastMalloc(
240 size.ValueOrDie(), WTF_HEAP_PROFILER_TYPE_NAME(XSLTProcessor)));
237 241
238 unsigned index = 0; 242 unsigned index = 0;
239 for (auto& parameter : parameters) { 243 for (auto& parameter : parameters) {
240 parameter_array[index++] = 244 parameter_array[index++] =
241 AllocateParameterArray(parameter.key.Utf8().data()); 245 AllocateParameterArray(parameter.key.Utf8().data());
242 parameter_array[index++] = 246 parameter_array[index++] =
243 AllocateParameterArray(parameter.value.Utf8().data()); 247 AllocateParameterArray(parameter.value.Utf8().data());
244 } 248 }
245 parameter_array[index] = 0; 249 parameter_array[index] = 0;
246 250
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 404
401 sheet->method = orig_method; 405 sheet->method = orig_method;
402 SetXSLTLoadCallBack(0, 0, 0); 406 SetXSLTLoadCallBack(0, 0, 0);
403 xsltFreeStylesheet(sheet); 407 xsltFreeStylesheet(sheet);
404 stylesheet_ = nullptr; 408 stylesheet_ = nullptr;
405 409
406 return success; 410 return success;
407 } 411 }
408 412
409 } // namespace blink 413 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/wtf/allocator/Partitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698