Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
fix potential segfault if login fails
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Nov 3, 2017
1 parent 92e4c64 commit 69ed6ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pvr.vdr.vnsi/addon.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.vdr.vnsi"
version="3.4.4"
version="3.4.5"
name="VDR VNSI Client"
provider-name="FernetMenta, Team Kodi">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
32 changes: 12 additions & 20 deletions src/VNSISession.cpp
Expand Up @@ -121,43 +121,35 @@ bool cVNSISession::Login()
if (!vresp)
throw "failed to read greeting from server";

uint32_t protocol = vresp->extract_U32();
uint32_t vdrTime = vresp->extract_U32();
int32_t vdrTimeOffset = vresp->extract_S32();
const char *ServerName = vresp->extract_String();
uint32_t protocol = vresp->extract_U32();
uint32_t vdrTime = vresp->extract_U32();
int32_t vdrTimeOffset = vresp->extract_S32();
const char *ServerName = vresp->extract_String();
const char *ServerVersion = vresp->extract_String();

m_server = ServerName;
m_version = ServerVersion;
m_protocol = (int)protocol;
m_server = ServerName;
m_version = ServerVersion;
m_protocol = (int)protocol;

if (m_protocol < VNSI_MIN_PROTOCOLVERSION)
throw "Protocol versions do not match";

if (m_name.empty())
{
XBMC->Log(LOG_NOTICE, "Logged in at '%lu+%i' to '%s' Version: '%s' with protocol version '%d'",
vdrTime, vdrTimeOffset, ServerName, ServerVersion, protocol);
vdrTime, vdrTimeOffset, ServerName, ServerVersion, protocol);
}
}
catch (const std::out_of_range& e)
{
XBMC->Log(LOG_ERROR, "%s - %s", __FUNCTION__, e.what());
if (m_socket)
{
m_socket->Close();
delete m_socket;
m_socket = NULL;
}
Close();
return false;
}
catch (const char * str)
{
XBMC->Log(LOG_ERROR, "%s - %s", __FUNCTION__,str);
if (m_socket)
{
m_socket->Close();
delete m_socket;
m_socket = NULL;
}
Close();
return false;
}

Expand Down

0 comments on commit 69ed6ed

Please sign in to comment.