Using `SoapySDRArgInfoList_clear()` on an `ArgInfoList` results in invalid `free()`

We built a SoapySDR loopback module for internal testing, based off of the rtlsdr codebase. During implementation, we borrowed the structure of functions such as getSettingInfo, however we've noticed that, after obtaining the argument info lists via SoapySDRDevice_getSettingInfo(), if we then try to free the list via SoapySDRArgInfoList_clear(), there is an invalid free() triggered upon the freeing of the string pointers. We believe this is due to the usage of string literals being assigned to the char * elements of the ArgInfoList structure, followed by these free() calls.

I see two possible ways forward:

  • We could pass all string literals through strdup() such that those free() calls are operating on actually allocated memory.
  • We could eliminate the free() calls somehow; either by never freeing such strings, or by embedding a bitmap that enables/disables freeing of certain pieces of memory.

In practice, I doubt many users are calling this function in a loop, so perhaps the memory accounting here is not so necessary for usual use. I just hate to see a memory leak anywhere.