aboutsummaryrefslogtreecommitdiff
path: root/lib/cximage-6.0/CxImage/xmemfile.cpp
diff options
context:
space:
mode:
authorMartijn Kaijser <machine.sanctum@gmail.com>2013-09-26 10:32:03 -0700
committerMartijn Kaijser <machine.sanctum@gmail.com>2013-09-26 10:32:03 -0700
commit679d7b2000484fb91f30e3d2046ea017d7bb4042 (patch)
tree5e02f3b15cc15e1ac95fdeb21aeca775d92f41c5 /lib/cximage-6.0/CxImage/xmemfile.cpp
parent7c5b7e5513f72000cff1d1fcfe508328bf40bbb5 (diff)
parent91e36c2420b1074244347f676a4bdba4732ccc0c (diff)
Merge pull request #3332 from ace20022/cximage_fixes
[Fix] Some cximage fixes
Diffstat (limited to 'lib/cximage-6.0/CxImage/xmemfile.cpp')
-rw-r--r--lib/cximage-6.0/CxImage/xmemfile.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/cximage-6.0/CxImage/xmemfile.cpp b/lib/cximage-6.0/CxImage/xmemfile.cpp
index af8db945a3..5a72200238 100644
--- a/lib/cximage-6.0/CxImage/xmemfile.cpp
+++ b/lib/cximage-6.0/CxImage/xmemfile.cpp
@@ -186,9 +186,21 @@ bool CxMemFile::Alloc(DWORD dwNewLen)
// allocate new buffer
if (m_pBuffer == NULL) m_pBuffer = (BYTE*)malloc(dwNewBufferSize);
- else m_pBuffer = (BYTE*)realloc(m_pBuffer, dwNewBufferSize);
+ else
+ {
+ BYTE* new_buf = (BYTE*)realloc(m_pBuffer, dwNewBufferSize);
+ if (!new_buf)
+ {
+ free(m_pBuffer);
+ m_bFreeOnClose = false;
+ return false;
+ }
+ else
+ m_pBuffer = new_buf;
+ }
// I own this buffer now (caller knows nothing about it)
- m_bFreeOnClose = true;
+ if (m_pBuffer)
+ m_bFreeOnClose = true;
m_Edge = dwNewBufferSize;
}