diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-12-24 07:58:26 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-12-24 07:58:26 +0000 |
commit | 78a11cf648442816c346cac9a756b782c918067b (patch) | |
tree | d44696f02d4e99754b9f62dd03c036d5078efd65 /lib | |
parent | 99732ca57ba52fc78ac9a1c60f90b02ea9d028a2 (diff) | |
download | rockbox-78a11cf648442816c346cac9a756b782c918067b.tar.gz rockbox-78a11cf648442816c346cac9a756b782c918067b.zip |
Fix FS#11829 - %?xx<....> Crashes on targets where the %xx feature tag isnt avilable. rather hacky fix though better than crashing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28890 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib')
-rw-r--r-- | lib/skin_parser/skin_parser.c | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 80f5f61699..e9f0bf8b47 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c | |||
@@ -969,37 +969,55 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc | |||
969 | cursor = bookmark; | 969 | cursor = bookmark; |
970 | #endif | 970 | #endif |
971 | /* Parsing the children */ | 971 | /* Parsing the children */ |
972 | element->children = skin_alloc_children(children); | 972 | |
973 | if (!element->children) | 973 | /* Feature tags could end up having 0 children which breaks |
974 | return 0; | 974 | * the render in dangerous ways. Minor hack, but insert an empty |
975 | element->children_count = children; | 975 | * child. (e.g %?xx<foo> when xx isnt available ) */ |
976 | 976 | ||
977 | for(i = 0; i < children; i++) | 977 | if (children == 0) |
978 | { | 978 | { |
979 | element->children[i] = skin_parse_code_as_arg(&cursor); | 979 | const char* emptyline= ""; |
980 | if (element->children[i] == NULL) | 980 | children = 1; |
981 | return 0; | 981 | element->children = skin_alloc_children(children); |
982 | skip_whitespace(&cursor); | 982 | if (!element->children) |
983 | return 0; | ||
984 | element->children_count = children; | ||
985 | element->children[0] = skin_parse_code_as_arg(&emptyline); | ||
986 | } | ||
987 | else | ||
988 | { | ||
989 | element->children = skin_alloc_children(children); | ||
990 | if (!element->children) | ||
991 | return 0; | ||
992 | element->children_count = children; | ||
993 | |||
994 | for(i = 0; i < children; i++) | ||
995 | { | ||
996 | element->children[i] = skin_parse_code_as_arg(&cursor); | ||
997 | if (element->children[i] == NULL) | ||
998 | return 0; | ||
999 | skip_whitespace(&cursor); | ||
983 | #ifdef ROCKBOX | 1000 | #ifdef ROCKBOX |
984 | if ((element->tag->flags&FEATURE_TAG) && feature_available) | 1001 | if ((element->tag->flags&FEATURE_TAG) && feature_available) |
985 | cursor = conditional_end; | 1002 | cursor = conditional_end; |
986 | #endif | 1003 | #endif |
987 | 1004 | ||
988 | if(i < children - 1 && *cursor != ENUMLISTSEPARATESYM) | 1005 | if(i < children - 1 && *cursor != ENUMLISTSEPARATESYM) |
989 | { | 1006 | { |
990 | skin_error(SEPARATOR_EXPECTED, cursor); | 1007 | skin_error(SEPARATOR_EXPECTED, cursor); |
991 | return 0; | 1008 | return 0; |
992 | } | 1009 | } |
993 | else if(i == children - 1 && *cursor != ENUMLISTCLOSESYM) | 1010 | else if(i == children - 1 && *cursor != ENUMLISTCLOSESYM) |
994 | { | 1011 | { |
995 | skin_error(CLOSE_EXPECTED, cursor); | 1012 | skin_error(CLOSE_EXPECTED, cursor); |
996 | return 0; | 1013 | return 0; |
997 | } | 1014 | } |
998 | else | 1015 | else |
999 | { | 1016 | { |
1000 | cursor++; | 1017 | cursor++; |
1001 | } | 1018 | } |
1002 | } | 1019 | } |
1020 | } | ||
1003 | *document = cursor; | 1021 | *document = cursor; |
1004 | 1022 | ||
1005 | return 1; | 1023 | return 1; |