epics-base / normativeTypesCPP

normativeTypesCPP is an EPICS V4 C++ module
http://epics-pvdata.sourceforge.net/index.html
Other
2 stars 8 forks source link

Fix possible NULL deref in NTNDArray::getValueSize() #20

Open JJL772 opened 3 months ago

JJL772 commented 3 months ago

This showed up as a warning when compiling. The incorrect NULL check in NTNDArray::getValueSize() would result in NTNDArray::getValueSize() always returning 0, or crashing if there is no stored value.

As a result, it looks like NTNDArray::isValid() would almost always return false, unless compressedSize is also 0:

bool NTNDArray::isValid()
{
    int64 valueSize = getValueSize();
    int64 compressedSize = getCompressedDataSize()->get();
    if (valueSize != compressedSize)
        return false;
    ...
}