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

Side by Side Diff: tools/win/split_link/split_link.cc

Issue 15180002: Fix crash in super splity linker, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <windows.h> 5 #include <windows.h>
6 #include <shlwapi.h> 6 #include <shlwapi.h>
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 link_binary.push_back(original_link); 175 link_binary.push_back(original_link);
176 RunLinker(link_binary, msg); 176 RunLinker(link_binary, msg);
177 } 177 }
178 178
179 static void Fallback() { 179 static void Fallback() {
180 Fallback(NULL); 180 Fallback(NULL);
181 } 181 }
182 182
183 static unsigned char* SlurpFile(const wchar_t* path, size_t* length) { 183 static unsigned char* SlurpFile(const wchar_t* path, size_t* length) {
184 HANDLE file = CreateFile( 184 HANDLE file = CreateFile(
185 path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL); 185 path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
186 if (file == INVALID_HANDLE_VALUE) 186 if (file == INVALID_HANDLE_VALUE)
187 Fallback(L"couldn't open file"); 187 Fallback(L"couldn't open file");
188 LARGE_INTEGER file_size; 188 LARGE_INTEGER file_size;
189 if (!GetFileSizeEx(file, &file_size)) 189 if (!GetFileSizeEx(file, &file_size))
190 Fallback(L"couldn't get file size"); 190 Fallback(L"couldn't get file size");
191 *length = static_cast<size_t>(file_size.QuadPart); 191 *length = static_cast<size_t>(file_size.QuadPart);
192 unsigned char* buffer = static_cast<unsigned char*>(malloc(*length)); 192 unsigned char* buffer = static_cast<unsigned char*>(malloc(*length));
193 if (!ReadFile(file, buffer, *length, NULL, NULL)) 193 DWORD bytes_read = 0;
194 if (!ReadFile(file, buffer, *length, &bytes_read, NULL))
194 Fallback(L"couldn't read file"); 195 Fallback(L"couldn't read file");
195 return buffer; 196 return buffer;
196 } 197 }
197 198
198 static bool SplitLinkRequested(const wchar_t* rsp_path) { 199 static bool SplitLinkRequested(const wchar_t* rsp_path) {
199 size_t length; 200 size_t length;
200 unsigned char* data = SlurpFile(rsp_path, &length); 201 unsigned char* data = SlurpFile(rsp_path, &length);
201 bool flag_found = false; 202 bool flag_found = false;
202 if (data[0] == 0xff && data[1] == 0xfe) { 203 if (data[0] == 0xff && data[1] == 0xfe) {
203 // UTF-16LE 204 // UTF-16LE
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (SplitLinkRequested(&argv[rsp_file_index][1])) { 249 if (SplitLinkRequested(&argv[rsp_file_index][1])) {
249 vector<wstring> link_binary; 250 vector<wstring> link_binary;
250 link_binary.push_back(WPYTHON_PATH); 251 link_binary.push_back(WPYTHON_PATH);
251 link_binary.push_back(WSPLIT_LINK_SCRIPT_PATH); 252 link_binary.push_back(WSPLIT_LINK_SCRIPT_PATH);
252 RunLinker(link_binary, NULL); 253 RunLinker(link_binary, NULL);
253 } 254 }
254 255
255 // Otherwise, run regular linker silently. 256 // Otherwise, run regular linker silently.
256 Fallback(); 257 Fallback();
257 } 258 }
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