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

Side by Side Diff: printing/printing_context_win.cc

Issue 3454022: Fix a c_str() use-after-free bug in the printing code. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 3 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/printing_context.h" 5 #include "printing/printing_context.h"
6 6
7 #include <winspool.h> 7 #include <winspool.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/i18n/file_util_icu.h" 10 #include "base/i18n/file_util_icu.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Set the flag used by the AbortPrintJob dialog procedure. 255 // Set the flag used by the AbortPrintJob dialog procedure.
256 abort_printing_ = false; 256 abort_printing_ = false;
257 257
258 in_print_job_ = true; 258 in_print_job_ = true;
259 259
260 // Register the application's AbortProc function with GDI. 260 // Register the application's AbortProc function with GDI.
261 if (SP_ERROR == SetAbortProc(context_, &AbortProc)) 261 if (SP_ERROR == SetAbortProc(context_, &AbortProc))
262 return OnError(); 262 return OnError();
263 263
264 DOCINFO di = { sizeof(DOCINFO) }; 264 DOCINFO di = { sizeof(DOCINFO) };
265 di.lpszDocName = UTF16ToWide(document_name).c_str(); 265 const std::wstring& document_name_wide = UTF16ToWide(document_name);
266 di.lpszDocName = document_name_wide.c_str();
266 267
267 // Is there a debug dump directory specified? If so, force to print to a file. 268 // Is there a debug dump directory specified? If so, force to print to a file.
268 FilePath debug_dump_path = PrintedDocument::debug_dump_path(); 269 FilePath debug_dump_path = PrintedDocument::debug_dump_path();
269 if (!debug_dump_path.empty()) { 270 if (!debug_dump_path.empty()) {
270 // Create a filename. 271 // Create a filename.
271 std::wstring filename; 272 std::wstring filename;
272 Time now(Time::Now()); 273 Time now(Time::Now());
273 filename = base::TimeFormatShortDateNumeric(now); 274 filename = base::TimeFormatShortDateNumeric(now);
274 filename += L"_"; 275 filename += L"_";
275 filename += base::TimeFormatTimeOfDay(now); 276 filename += base::TimeFormatTimeOfDay(now);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 if (buf_size) { 612 if (buf_size) {
612 buffer->reset(new uint8[buf_size]); 613 buffer->reset(new uint8[buf_size]);
613 memset(buffer->get(), 0, buf_size); 614 memset(buffer->get(), 0, buf_size);
614 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { 615 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) {
615 buffer->reset(); 616 buffer->reset();
616 } 617 }
617 } 618 }
618 } 619 }
619 620
620 } // namespace printing 621 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698