summaryrefslogtreecommitdiff
path: root/diskio-unix.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2011-06-10 01:16:51 -0400
committersrs5694 <srs5694@users.sourceforge.net>2011-06-10 01:16:51 -0400
commit6aae2a9b70e9f88926baad94c1eea40e0b534f01 (patch)
tree1e6d2e25970f415091b8f6518eb1f6d8e0988847 /diskio-unix.cc
parent699941e25a1fcf0beec124203747c8ed20842989 (diff)
downloadsgdisk-6aae2a9b70e9f88926baad94c1eea40e0b534f01.tar.gz
Miscellaneous bug fixes.
Diffstat (limited to 'diskio-unix.cc')
-rw-r--r--diskio-unix.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/diskio-unix.cc b/diskio-unix.cc
index 5494dd5..327a498 100644
--- a/diskio-unix.cc
+++ b/diskio-unix.cc
@@ -290,6 +290,10 @@ 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
retval = read(fd, tempSpace, numBlocks * blockSize);
@@ -328,7 +332,11 @@ 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
memcpy(tempSpace, buffer, numBytes);
for (i = numBytes; i < numBlocks * blockSize; i++) {