diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2011-06-10 01:16:51 -0400 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2011-06-10 01:16:51 -0400 |
commit | 6aae2a9b70e9f88926baad94c1eea40e0b534f01 (patch) | |
tree | 1e6d2e25970f415091b8f6518eb1f6d8e0988847 /diskio-windows.cc | |
parent | 699941e25a1fcf0beec124203747c8ed20842989 (diff) | |
download | sgdisk-6aae2a9b70e9f88926baad94c1eea40e0b534f01.tar.gz |
Miscellaneous bug fixes.
Diffstat (limited to 'diskio-windows.cc')
-rw-r--r-- | diskio-windows.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/diskio-windows.cc b/diskio-windows.cc index 938d7ec..37e5bb5 100644 --- a/diskio-windows.cc +++ b/diskio-windows.cc @@ -230,7 +230,11 @@ int DiskIO::Read(void* buffer, int numBytes) { numBlocks++; tempSpace = new char [numBlocks * blockSize]; } // if/else - + if (tempSpace == NULL) { + cerr << "Unable to allocate memory in DiskIO::Read()! Terminating!\n"; + exit(1); + } // if + // Read the data into temporary space, then copy it to buffer ReadFile(fd, tempSpace, numBlocks * blockSize, &retval, NULL); for (i = 0; i < numBytes; i++) { @@ -271,6 +275,10 @@ int DiskIO::Write(void* buffer, int numBytes) { if ((numBytes % blockSize) != 0) numBlocks++; tempSpace = new char [numBlocks * blockSize]; } // if/else + if (tempSpace == NULL) { + cerr << "Unable to allocate memory in DiskIO::Write()! Terminating!\n"; + exit(1); + } // if // Copy the data to my own buffer, then write it for (i = 0; i < numBytes; i++) { |