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

Side by Side Diff: chrome/utility/importer/ie_importer_win.cc

Issue 695553003: Fix bug found by /analyze: incorrect return checking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/utility/importer/ie_importer_win.h" 5 #include "chrome/utility/importer/ie_importer_win.h"
6 6
7 #include <ole2.h> 7 #include <ole2.h>
8 #include <intshcut.h> 8 #include <intshcut.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #include <urlhist.h> 10 #include <urlhist.h>
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 // Read the sort index of the current item. 191 // Read the sort index of the current item.
192 uint32 item_sort_index = 0; 192 uint32 item_sort_index = 0;
193 if (!BinaryRead(&item_sort_index, base_offset + kSortIndexOffset, blob)) 193 if (!BinaryRead(&item_sort_index, base_offset + kSortIndexOffset, blob))
194 return false; 194 return false;
195 195
196 // Read the file name from the ITEMIDLIST structure. 196 // Read the file name from the ITEMIDLIST structure.
197 LPCITEMIDLIST idlist = BinaryReadItemIDList( 197 LPCITEMIDLIST idlist = BinaryReadItemIDList(
198 base_offset + kItemIDListOffset, item_size - kItemIDListOffset, blob); 198 base_offset + kItemIDListOffset, item_size - kItemIDListOffset, blob);
199 TCHAR item_filename[MAX_PATH]; 199 TCHAR item_filename[MAX_PATH];
200 if (!idlist || FAILED(SHGetPathFromIDList(idlist, item_filename))) 200 if (!idlist || !SHGetPathFromIDList(idlist, item_filename))
scottmg 2014/10/31 22:40:53 Yup, that just looks wrong.
201 return false; 201 return false;
202 base::FilePath item_relative_path = 202 base::FilePath item_relative_path =
203 path.Append(base::FilePath(item_filename).BaseName()); 203 path.Append(base::FilePath(item_filename).BaseName());
204 204
205 // Record the retrieved information and go to the next item. 205 // Record the retrieved information and go to the next item.
206 sort_index->insert(std::make_pair(item_relative_path, item_sort_index)); 206 sort_index->insert(std::make_pair(item_relative_path, item_sort_index));
207 base_offset += item_size; 207 base_offset += item_size;
208 } 208 }
209 return true; 209 return true;
210 } 210 }
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 favicons->push_back(iter->second); 870 favicons->push_back(iter->second);
871 } 871 }
872 872
873 int IEImporter::CurrentIEVersion() const { 873 int IEImporter::CurrentIEVersion() const {
874 static int version = -1; 874 static int version = -1;
875 if (version < 0) { 875 if (version < 0) {
876 wchar_t buffer[128]; 876 wchar_t buffer[128];
877 DWORD buffer_length = sizeof(buffer); 877 DWORD buffer_length = sizeof(buffer);
878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); 878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ);
879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); 879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL);
880 buffer[arraysize(buffer) - 1] = 0;
scottmg 2014/10/31 22:40:53 the docs http://msdn.microsoft.com/en-us/library/w
Ilya Sherman 2014/10/31 22:45:05 Agreed, using a function that guarantees a null-te
880 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); 881 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0);
881 } 882 }
882 return version; 883 return version;
883 } 884 }
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