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

Side by Side Diff: testing/test_support.cpp

Issue 1568763003: Fix a GetFileContents() call that should have been in commit aa326bd6. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 11 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 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium 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 "testing/test_support.h" 5 #include "testing/test_support.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "testing/utils/path_service.h" 10 #include "testing/utils/path_service.h"
(...skipping 27 matching lines...) Expand all
38 return result; 38 return result;
39 } 39 }
40 40
41 bool GetExternalData(const std::string& exe_path, 41 bool GetExternalData(const std::string& exe_path,
42 const std::string& bin_dir, 42 const std::string& bin_dir,
43 const std::string& filename, 43 const std::string& filename,
44 v8::StartupData* result_data) { 44 v8::StartupData* result_data) {
45 std::string full_path = 45 std::string full_path =
46 GetFullPathForSnapshotFile(exe_path, bin_dir, filename); 46 GetFullPathForSnapshotFile(exe_path, bin_dir, filename);
47 size_t data_length = 0; 47 size_t data_length = 0;
48 char* data_buffer = GetFileContents(full_path.c_str(), &data_length); 48 std::unique_ptr<char, pdfium::FreeDeleter> data_buffer =
49 if (!data_buffer) { 49 GetFileContents(full_path.c_str(), &data_length);
50 if (!data_buffer)
50 return false; 51 return false;
51 } 52
52 result_data->data = const_cast<const char*>(data_buffer); 53 result_data->data = data_buffer.release();
53 result_data->raw_size = data_length; 54 result_data->raw_size = data_length;
54 return true; 55 return true;
55 } 56 }
56 #endif // V8_USE_EXTERNAL_STARTUP_DATA 57 #endif // V8_USE_EXTERNAL_STARTUP_DATA
57 58
58 void InitializeV8Common(v8::Platform** platform) { 59 void InitializeV8Common(v8::Platform** platform) {
59 v8::V8::InitializeICU(); 60 v8::V8::InitializeICU();
60 61
61 *platform = v8::platform::CreateDefaultPlatform(); 62 *platform = v8::platform::CreateDefaultPlatform();
62 v8::V8::InitializePlatform(*platform); 63 v8::V8::InitializePlatform(*platform);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 unsigned long pos, 165 unsigned long pos,
165 unsigned char* pBuf, 166 unsigned char* pBuf,
166 unsigned long size) { 167 unsigned long size) {
167 TestLoader* pLoader = static_cast<TestLoader*>(param); 168 TestLoader* pLoader = static_cast<TestLoader*>(param);
168 if (pos + size < pos || pos + size > pLoader->m_Len) 169 if (pos + size < pos || pos + size > pLoader->m_Len)
169 return 0; 170 return 0;
170 171
171 memcpy(pBuf, pLoader->m_pBuf + pos, size); 172 memcpy(pBuf, pLoader->m_pBuf + pos, size);
172 return 1; 173 return 1;
173 } 174 }
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