mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
prevent possible segfault std::string if value NULL
This commit is contained in:
@@ -271,13 +271,16 @@ void deleteOldfileEvents(char *epgdir)
|
||||
filter = filter->xmlChildrenNode;
|
||||
|
||||
while (filter) {
|
||||
filename = xmlGetAttribute(filter, "name");
|
||||
const char * name = xmlGetAttribute(filter, "name");
|
||||
if(name){
|
||||
filename=name;
|
||||
file = epgdir;
|
||||
file +="/";
|
||||
file +=filename;
|
||||
unlink(file.c_str());
|
||||
filter = filter->xmlNextNode;
|
||||
}
|
||||
}
|
||||
xmlFreeDoc(filter_parser);
|
||||
}
|
||||
}
|
||||
@@ -313,7 +316,10 @@ void *insertEventsfromFile(void * data)
|
||||
eventfile = xmlDocGetRootElement(index_parser)->xmlChildrenNode;
|
||||
|
||||
while (eventfile) {
|
||||
filename = xmlGetAttribute(eventfile, "name");
|
||||
const char * name = xmlGetAttribute(eventfile, "name");
|
||||
if(name)
|
||||
filename=name;
|
||||
|
||||
epgname = epg_dir + filename;
|
||||
if (!(event_parser = parseXmlFile(epgname.c_str()))) {
|
||||
dprintf("unable to open %s for reading\n", epgname.c_str());
|
||||
|
@@ -481,7 +481,9 @@ printf("CFileBrowser::readDir_sc: read done, size %d\n", (int)answer.size());
|
||||
CFile file;
|
||||
if (xml_decode == 1) {
|
||||
file.Mode = S_IFDIR + 0777 ;
|
||||
file.Name = xmlGetAttribute(element, "name");
|
||||
const char *eptr = xmlGetAttribute(element, "name");
|
||||
if(eptr)
|
||||
file.Name = eptr;
|
||||
file.Url = sc_get_genre + file.Name;
|
||||
file.Size = 0;
|
||||
file.Time = 0;
|
||||
@@ -498,8 +500,14 @@ printf("CFileBrowser::readDir_sc: read done, size %d\n", (int)answer.size());
|
||||
ptr = xmlGetAttribute(element, "mt");
|
||||
if (ptr && (strcmp(ptr, "audio/mpeg")==0)) {
|
||||
file.Mode = S_IFREG + 0777 ;
|
||||
file.Name = xmlGetAttribute(element, "name");
|
||||
file.Url = sc_tune_in_base + tunein_base + (std::string)"?id=" + xmlGetAttribute(element, "id") + (std::string)"&k=" + g_settings.shoutcast_dev_id;
|
||||
const char *aptr = xmlGetAttribute(element, "name");
|
||||
if(aptr)
|
||||
file.Name = aptr;
|
||||
const char *idptr = xmlGetAttribute(element, "id");
|
||||
std::string id;
|
||||
if(idptr)
|
||||
id = idptr;
|
||||
file.Url = sc_tune_in_base + tunein_base + (std::string)"?id=" + id + (std::string)"&k=" + g_settings.shoutcast_dev_id;
|
||||
//printf("adding %s (%s)\n", file.Name.c_str(), file.Url.c_str());
|
||||
ptr = xmlGetAttribute(element, "br");
|
||||
if (ptr) {
|
||||
|
@@ -146,17 +146,23 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems()
|
||||
{
|
||||
if (!strcmp(xmlGetName(search), "zone"))
|
||||
{
|
||||
std::string name = xmlGetAttribute(search, "name");
|
||||
std::string zone = xmlGetAttribute(search, "zone");
|
||||
const char* zptr = xmlGetAttribute(search, "zone");
|
||||
std::string zone;
|
||||
if(zptr)
|
||||
zone = zptr;
|
||||
//printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str());
|
||||
if (access("/usr/share/zoneinfo/" + zone, R_OK))
|
||||
printf("[neutrino] timezone file '%s' not installed\n", zone.c_str());
|
||||
else
|
||||
{
|
||||
const char* ptr = xmlGetAttribute(search, "name");
|
||||
if(ptr){
|
||||
std::string name = ptr;
|
||||
tzSelect->addOption(name);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
search = search->xmlNextNode;
|
||||
}
|
||||
|
||||
@@ -172,7 +178,6 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems()
|
||||
return tzSelect;
|
||||
}
|
||||
|
||||
|
||||
//shows locale setup for language selection
|
||||
void COsdLangSetup::showLanguageSetup(CMenuWidget *osdl_setup)
|
||||
{
|
||||
|
@@ -453,9 +453,14 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data)
|
||||
xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode;
|
||||
while (search) {
|
||||
if (!strcmp(xmlGetName(search), "zone")) {
|
||||
name = xmlGetAttribute(search, "name");
|
||||
const char *nptr = xmlGetAttribute(search, "name");
|
||||
if(nptr)
|
||||
name = nptr;
|
||||
|
||||
if(g_settings.timezone == name) {
|
||||
zone = xmlGetAttribute(search, "zone");
|
||||
const char *zptr = xmlGetAttribute(search, "zone");
|
||||
if(zptr)
|
||||
zone = zptr;
|
||||
if (!access("/usr/share/zoneinfo/" + zone, R_OK))
|
||||
found = true;
|
||||
break;
|
||||
|
@@ -443,7 +443,10 @@ void CServiceManager::ParseChannels(xmlNodePtr node, const t_transport_stream_id
|
||||
while ((node = xmlGetNextOccurence(node, "S")) != NULL) {
|
||||
*have_ptr = 1;
|
||||
t_service_id service_id = xmlGetNumericAttribute(node, "i", 16);
|
||||
std::string name = xmlGetAttribute(node, "n");
|
||||
std::string name;
|
||||
const char *nptr = xmlGetAttribute(node, "n");
|
||||
if(nptr)
|
||||
name = nptr;
|
||||
uint8_t service_type = xmlGetNumericAttribute(node, "t", 16);
|
||||
uint16_t vpid = xmlGetNumericAttribute(node, "v", 16);
|
||||
uint16_t apid = xmlGetNumericAttribute(node, "a", 16);
|
||||
|
Reference in New Issue
Block a user