Index: xfa/src/fxbarcode/common/BC_CommonByteArray.cpp |
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp |
index e085ffcec2c192269d01416fe3f2d0fdba101049..1a6ef9f63fa59e67325f0a4ad33eefcd05e1d81b 100644 |
--- a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp |
+++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp |
@@ -42,12 +42,7 @@ CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) { |
m_index = size; |
} |
CBC_CommonByteArray::~CBC_CommonByteArray() { |
- if (m_bytes != NULL) { |
- FX_Free(m_bytes); |
- m_bytes = NULL; |
- } |
- m_index = 0; |
- m_size = 0; |
+ FX_Free(m_bytes); |
} |
int32_t CBC_CommonByteArray::At(int32_t index) { |
return m_bytes[index] & 0xff; |
@@ -72,19 +67,19 @@ void CBC_CommonByteArray::AppendByte(int32_t value) { |
void CBC_CommonByteArray::Reserve(int32_t capacity) { |
if (m_bytes == NULL || m_size < capacity) { |
uint8_t* newArray = FX_Alloc(uint8_t, capacity); |
- FXSYS_memset(newArray, 0, capacity); |
- if (m_bytes != NULL) { |
+ if (m_bytes) { |
FXSYS_memcpy(newArray, m_bytes, m_size); |
- FX_Free(m_bytes); |
+ FXSYS_memset(newArray + m_size, 0, capacity - m_size); |
+ } else { |
+ FXSYS_memset(newArray, 0, capacity); |
} |
+ FX_Free(m_bytes); |
m_bytes = newArray; |
m_size = capacity; |
} |
} |
void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) { |
- if (m_bytes != NULL) { |
- FX_Free(m_bytes); |
- } |
+ FX_Free(m_bytes); |
m_bytes = FX_Alloc(uint8_t, count); |
m_size = count; |
FXSYS_memcpy(m_bytes, source + offset, count); |
@@ -93,9 +88,7 @@ void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) { |
void CBC_CommonByteArray::Set(CFX_ByteArray* source, |
int32_t offset, |
int32_t count) { |
- if (m_bytes != NULL) { |
- FX_Free(m_bytes); |
- } |
+ FX_Free(m_bytes); |
m_bytes = FX_Alloc(uint8_t, count); |
m_size = count; |
int32_t i; |