[cmyth] Fix memory leak in cmyth_livetv_chain_add_url

This fixes memory leak in cmyth_livetv_chain_add_url in case ref_realloc
fails.
[cmyth] Fix assign instead of copy error in cmyth_rcv_timestamp
[cmyth] Store cmyth_send_msg return code in r instead of err

This prevents this lines from being detected as copy/paste errors.
[cmyth] Fix uninitialized access in cmyth_mysql_keep_livetv_recording

This fixes accessing uninitialized autoexpire value in case we fail to
read the AutoExpireDefault value from the database.
[cmyth] Fix memory leak in recordingrule

The fields subtitle and callsign were not freed when a recordingrule is
destroyed.
[cmyth] Fix memory leak in recordingrule timestamps

The fields starttime and endtime are initialized by copy in
cmyth_mysql_get_recordingrules. Therefore it's not necessary to allocate
memory in cmyth_recordingrule_create.

The existing code leaks memory when overriding starttime and endtime
in mythtv_mysql.c with cmyth_timestamp_from_unixtime.
[cmyth] Add fblen parameter for cmyth_rcv_feedback

The function cmyth_rcv_feedback was incorrectly using sizeof for
retrieving the string length of a character pointer.

The patch improves this by adding a fblen parameter and requiring the
caller to explicitly specify the length of the feedback that the
function should check.
[cmyth] Don't read after free in ref_release

A refcount of <0 indicates an error and prints the ref.
In case we freed ref, we must not enter this path.
[cmyth] Replace non-portable sizeof in cmyth_proglist_sort
[mythtv-cmyth] Pass PVR_TIMER as const ref in PVRtoMythRecordingRule

Avoid copying struct PVR_TIMER since its size is around 3000 bytes.
[mythtv-cmyth] Don't deref non found recRule in GetTimers

In addition, use std::distance to find the iterator index.
[cmyth] Remove cmyth_mysql_get_commbreaklist

This commit removes the functions cmyth_mysql_get_commbreaklist,
cmyth_mysql_query_commbreak_count and cmyth_mysql_query_commbreak_list.

As a replacement, cmyth_get_commbreaklist should be used.

Reasons for removing cmyth_mysql_query_commbreak_list:
- Memory leaks and dereferencing null pointer in case when an incorrect
  dataset is received
- Different implementations based on protocol version, should use db
  schema version instead
- Slow algorithm
[mythtv-cmyth] Zero buffer in MythEventHandlerPrivate::SetRecordingEventListener

Conditional jump or move depends on uninitialised value(s)
  at 0x4C2D7A9: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x589B5FB: std::string::assign(char const*) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17)
  by 0x40EBE7: void ssasn<char>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*) (StdString.h:1300)
  by 0x50562B: MythEventHandler::MythEventHandlerPrivate::SetRecordingEventListener(CStdStr<char> const&, MythFile const&) (StdString.h:2179)
  by 0x5056FB: MythEventHandler::SetRecordingListener(CStdStr<char> const&, MythFile const&) (MythEventHandler.cpp:585)
  by 0x4DA944: PVRClientMythTV::OpenRecordedStream(PVR_RECORDING const&) (pvrclient-mythtv.cpp:1718)
...
Uninitialised value was created by a stack allocation
  at 0x5055C0: MythEventHandler::MythEventHandlerPrivate::SetRecordingEventListener(CStdStr<char> const&, MythFile const&) (MythEventHandler.cpp:362)
[cmyth] Fix access of freed memory in cmyth_livetv_chain_setup

Invalid read of size 2
  at 0x53A673: cmyth_livetv_chain_setup (livetv.c:723)
  by 0x53B73E: cmyth_spawn_live_tv (livetv.c:1318)
  by 0x510EF2: MythRecorder::SpawnLiveTV(MythChannel&) (MythRecorder.cpp:162)
  by 0x4E9F3C: PVRClientMythTV::OpenLiveStream(PVR_CHANNEL const&) (pvrclient-mythtv.cpp:1455)
[mythtv-cmyth] Use term 'Storage Group' when loading files

The current code confuses the term recording group and storage group
when loading files.

Files (like previews icons, artworks and streams) are accessible by their
storage group.

Whereas recording groups are used to set user-defined categories for
recordings (like Movies, Kids, ...).
[mythtv-cmyth] Add MythProgramInfo::StorageGroup

The function returns the recording's storage group.
[mythtv-cmyth] Use StorageGroup instead of RecordingGroup when loading preview

Prevents mythbackend errors like:
  Unable to find any directories for the local storage group 'Movies' on
    'myhost', trying directories on all hosts!
  Unable to find storage group 'Movies', trying 'Default' group!
[mythtv-cmyth] Use recording UID fram map instead re-requesting it
[mythtv-cmyth] Improve MythProgramInfo::UID
[mythtv-cmyth] Fix memory leak in MythProgramInfo::StorageGroup

The function cmyth_proginfo_storagegroup increases the reference counter
using ref_hold. Therefore we have to decrease it again with ref_release.

This issue was introduced in d06317d39a9c65239eb8cf909bec821c44bfd0eb.

3,520 bytes in 110 blocks are definitely lost in loss record 6 of 8
  at 0x4C2CD7B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x55F5FE: __ref_alloc (alloc.c:275)
  by 0x55F835: ref_strdup (alloc.c:412)
  by 0x55BB48: __cmyth_rcv_proginfo (socket.c:2235)
  by 0x55CB89: __cmyth_rcv_proglist (socket.c:2642)
  by 0x5536C8: cmyth_proglist_get_list (proglist.c:271)
  by 0x553D2C: cmyth_proglist_get_all_recorded (proglist.c:329)
  by 0x50510A: MythConnection::GetRecordedPrograms() (MythConnection.cpp:237)
  by 0x4ED1CB: PVRClientMythTV::FillRecordings() (pvrclient-mythtv.cpp:721)
  by 0x4EEF83: PVRClientMythTV::GetRecordings(ADDON_HANDLE_STRUCT*) (pvrclient-mythtv.cpp:521)