Problem Description
The C wrapper around SoapySDR::ArgInfo looks like this:
static inline SoapySDRArgInfo toArgInfo(const SoapySDR::ArgInfo &info)
{
SoapySDRArgInfo out;
std::memset(&out, 0, sizeof(out));
try
{
...
out.optionNames = toStrArray(info.optionNames, &out.numOptions);
// do options after optionNames so correct numOptions is reported if no optionNames
out.options = toStrArray(info.options, &out.numOptions);
When info.options has elements but info.optionNames doesn't, out.optionNames is assigned a pointer to a zero-length memory. The calling code has no way to know that, when it tries to read numOptions entries from that memory, an AV exception is fired.
Proposed Fix
Change toStrArray to return NULL when strs has no entries
static inline char **toStrArray(const std::vector<std::string> &strs, size_t *length)
{
if (strs.size() == 0) return NULL;
...
and make a corresponding change inSoapySDRStrings_clear:
void SoapySDRStrings_clear(char ***elems, const size_t length)
{
if (*elems == NULL) return;
...
Problem Description
The C wrapper around
SoapySDR::ArgInfolooks like this:When
info.optionshas elements butinfo.optionNamesdoesn't,out.optionNamesis assigned a pointer to a zero-length memory. The calling code has no way to know that, when it tries to readnumOptionsentries from that memory, an AV exception is fired.Proposed Fix
Change
toStrArrayto returnNULLwhenstrshas no entriesand make a corresponding change in
SoapySDRStrings_clear: