Skip to content

Commit

Permalink
Merge pull request xbmc#25581 from ksooo/pvr-fix-gettimertypes-crash
Browse files Browse the repository at this point in the history
[PVR] CPVRClients::UpdateTimerTypes: Fix crash with addons not suppor…
  • Loading branch information
ksooo authored Aug 9, 2024
2 parents 40650f5 + 2aeb572 commit 43a9ba4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions xbmc/pvr/addons/PVRClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,16 +1297,18 @@ PVR_ERROR CPVRClient::UpdateTimerTypes()
types_array = new PVR_TIMER_TYPE*[size];

// manual one time
(*types_array)[0].iId = 1;
(*types_array)[0].iAttributes =
types_array[0] = new PVR_TIMER_TYPE{};
types_array[0]->iId = 1;
types_array[0]->iAttributes =
PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | PVR_TIMER_TYPE_SUPPORTS_START_TIME |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | PVR_TIMER_TYPE_SUPPORTS_PRIORITY |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS;

// manual timer rule
(*types_array)[1].iId = 2;
(*types_array)[1].iAttributes =
types_array[1] = new PVR_TIMER_TYPE{};
types_array[1]->iId = 2;
types_array[1]->iAttributes =
PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_IS_REPEATING |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | PVR_TIMER_TYPE_SUPPORTS_CHANNELS |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | PVR_TIMER_TYPE_SUPPORTS_END_TIME |
Expand All @@ -1317,8 +1319,9 @@ PVR_ERROR CPVRClient::UpdateTimerTypes()
if (m_clientCapabilities.SupportsEPG())
{
// One-shot epg-based
(*types_array)[2].iId = 3;
(*types_array)[2].iAttributes =
types_array[2] = new PVR_TIMER_TYPE{};
types_array[2]->iId = 3;
types_array[2]->iAttributes =
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | PVR_TIMER_TYPE_SUPPORTS_START_TIME |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | PVR_TIMER_TYPE_SUPPORTS_PRIORITY |
Expand All @@ -1339,14 +1342,18 @@ PVR_ERROR CPVRClient::UpdateTimerTypes()
CLog::LogF(LOGERROR, "Invalid timer type supplied by add-on {}.", GetID());
continue;
}
timerTypes.emplace_back(std::make_shared<CPVRTimerType>(*types_array[i], m_iClientId));
timerTypes.emplace_back(
std::make_shared<CPVRTimerType>(*(types_array[i]), m_iClientId));
}
}

/* free the resources of the timer types array */
if (array_owner)
{
// begin compat section
for (unsigned int i = 0; i < size; ++i)
delete types_array[i];

delete[] types_array;
// end compat section
}
Expand Down

0 comments on commit 43a9ba4

Please sign in to comment.