initReceiver can potentially use NULL pointer for rist_logging_settings
bool RISTNetReceiver::initReceiver(std::vector<std::string> &rURLList,
RISTNetReceiver::RISTNetReceiverSettings &rSettings) {
...
// Default log settings
rist_logging_settings* lSettingsPtr = rSettings.mLogSetting.get();
lStatus = rist_logging_set(&lSettingsPtr, rSettings.mLogLevel, nullptr, nullptr, nullptr, stderr);
mLoggingScope.reset(lSettingsPtr);
if (lStatus) {
LOGGER(true, LOGG_ERROR, "rist_logging_set failed.")
return false;
}
lStatus = rist_receiver_create(&mRistContext, rSettings.mProfile, rSettings.mLogSetting.get()); // --> Problem here
if (lStatus) {
LOGGER(true, LOGG_ERROR, "rist_receiver_create fail.")
return false;
}
...
If initReceiver
is called with a freshly created RistNetReceiverSettings
(like in the example in the README), rSettings.mLogSetting.get()
will point to NULL.
This is not a problem when calling rist_logging_set(&lSettingsPtr...)
because inside that function, the struct will be created if the pointer is NULL (rist/src/logging.c:211).
But when rist_receiver_create
is called using rSettings.mLogSetting.get()
, that still points to NULL and leads to a crash.
A partial solution can be this (use lSettingsPtr
because it was initialized in logging.c):
lStatus = rist_receiver_create(&mRistContext, rSettings.mProfile, lSettingsPtr);
But rSettings.mLogSetting
keeps as a null pointer, so maybe there is a better solution.
This also happens for initSender()
.
EDIT: if anyone sees this, i fixed it in https://github.com/swxtchio/rist-cpp/pull/4/files