From: skeezix Date: Tue, 8 Feb 2011 16:32:05 +0000 (-0500) Subject: libpnd: repaired bugs #128 and #150 from tracker, relating to pnd-discovery crashing... X-Git-Tag: sz_beta3~82 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8003661082444fef2d6ca4d1581da8792a1a1de;p=pandora-libraries.git libpnd: repaired bugs #128 and #150 from tracker, relating to pnd-discovery crashing when PXMLs had lots of tags; realloc() miscalculation. Test cases now included in testdata/apps/sebt3*. Thanks Sebastian! --- diff --git a/include/pnd_pxml.h b/include/pnd_pxml.h index 037d0c2..bca88f4 100644 --- a/include/pnd_pxml.h +++ b/include/pnd_pxml.h @@ -23,8 +23,8 @@ typedef void* pnd_pxml_handle; /* pxml_fetch() will return NULL on fail, otherwise a valid handle which may be further queried */ -pnd_pxml_handle *pnd_pxml_fetch ( char *fullpath ); -pnd_pxml_handle *pnd_pxml_fetch_buffer ( char *filename, char *buffer ); +pnd_pxml_handle *pnd_pxml_fetch ( char *fullpath ); // fetch from file +pnd_pxml_handle *pnd_pxml_fetch_buffer ( char *filename, char *buffer ); // fetch from a buffer void pnd_pxml_delete ( pnd_pxml_handle h ); /* overrides() allow for customization of a PXML that persists; ie: An application might be sitting diff --git a/lib/pnd_tinyxml.cpp b/lib/pnd_tinyxml.cpp index 95cf3ec..2c6d4e9 100644 --- a/lib/pnd_tinyxml.cpp +++ b/lib/pnd_tinyxml.cpp @@ -80,24 +80,25 @@ unsigned char pnd_pxml_parse_descriptions(const TiXmlHandle hRoot, pnd_pxml_t *a continue; } - char *text = strdup(pElem->GetText()); - if (!text) continue; - - char *lang = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_DESCRLANG); - if (!lang) continue; - - app->descriptions_c++; - if (app->descriptions_c > app->descriptions_alloc_c) //we don't have enough strings allocated - { - app->descriptions_alloc_c <<= 1; - app->descriptions = (pnd_localized_string_t*)realloc((void*)app->descriptions, app->descriptions_alloc_c); - if (!app->descriptions) return (0); //errno = ENOMEM - } - - pnd_localized_string_t *description = &app->descriptions[app->descriptions_c - 1]; - description->language = lang; - description->string = text; + char *text = strdup(pElem->GetText()); + if (!text) continue; + + char *lang = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_DESCRLANG); + if (!lang) continue; + + app->descriptions_c++; + if (app->descriptions_c > app->descriptions_alloc_c) //we don't have enough strings allocated + { + app->descriptions_alloc_c <<= 1; + app->descriptions = (pnd_localized_string_t*)realloc((void*)app->descriptions, app->descriptions_alloc_c * sizeof(pnd_localized_string_t) ); + if (!app->descriptions) return (0); //errno = ENOMEM + } + + pnd_localized_string_t *description = &app->descriptions[app->descriptions_c - 1]; + description->language = lang; + description->string = text; } + return (1); } diff --git a/testdata/apps/sebt3badapp-bug128/PXML.xml b/testdata/apps/sebt3badapp-bug128/PXML.xml new file mode 100644 index 0000000..284efb7 --- /dev/null +++ b/testdata/apps/sebt3badapp-bug128/PXML.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + Audacious + Listen to music + Слухайце музыку + Musik hören + Écouter de la musique + Hallgasson zenét + Ascoltare musica + Klausyti muzikos + Muziek luisteren + Слушайте музыку + + + + + + + + + diff --git a/testdata/apps/sebt3badapp-bug150/PXML.xml b/testdata/apps/sebt3badapp-bug150/PXML.xml new file mode 100644 index 0000000..a1a7ae1 --- /dev/null +++ b/testdata/apps/sebt3badapp-bug150/PXML.xml @@ -0,0 +1,1094 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +