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

Unified Diff: base/shared_memory_posix.cc

Issue 11446048: The correct type for the size of a chunk of memory is size_t. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/shared_memory_nacl.cc ('k') | base/shared_memory_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_memory_posix.cc
===================================================================
--- base/shared_memory_posix.cc (revision 175576)
+++ base/shared_memory_posix.cc (working copy)
@@ -98,7 +98,7 @@
DPLOG(ERROR) << "close";
}
-bool SharedMemory::CreateAndMapAnonymous(uint32 size) {
+bool SharedMemory::CreateAndMapAnonymous(size_t size) {
return CreateAnonymous(size) && Map(size);
}
@@ -113,6 +113,9 @@
DCHECK_EQ(-1, mapped_file_);
if (options.size == 0) return false;
+ if (options.size > static_cast<size_t>(std::numeric_limits<int>::max()))
+ return false;
+
// This function theoretically can block on the disk, but realistically
// the temporary files we create will just go into the buffer cache
// and be deleted before they ever make it out to disk.
@@ -153,7 +156,7 @@
file_util::CloseFile(fp);
return false;
}
- const uint32 current_size = stat.st_size;
+ const size_t current_size = stat.st_size;
if (current_size != options.size) {
if (HANDLE_EINTR(ftruncate(fileno(fp), options.size)) != 0) {
file_util::CloseFile(fp);
@@ -216,10 +219,13 @@
#endif // !defined(OS_ANDROID)
-bool SharedMemory::Map(uint32 bytes) {
+bool SharedMemory::Map(size_t bytes) {
if (mapped_file_ == -1)
return false;
+ if (bytes > static_cast<size_t>(std::numeric_limits<int>::max()))
+ return false;
+
#if defined(OS_ANDROID)
if (bytes == 0) {
int ashmem_bytes = ashmem_get_size_region(mapped_file_);
« no previous file with comments | « base/shared_memory_nacl.cc ('k') | base/shared_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698