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-unix.cc | |
parent | 699941e25a1fcf0beec124203747c8ed20842989 (diff) | |
download | sgdisk-6aae2a9b70e9f88926baad94c1eea40e0b534f01.tar.gz |
Miscellaneous bug fixes.
Diffstat (limited to 'diskio-unix.cc')
-rw-r--r-- | diskio-unix.cc | 10 |
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++) { |