diff options
Diffstat (limited to 'lib/skin_parser/skin_parser.c')
-rw-r--r-- | lib/skin_parser/skin_parser.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 3554629608..f92a52774d 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c | |||
@@ -38,6 +38,8 @@ int skin_line = 0; | |||
38 | char* skin_start = 0; | 38 | char* skin_start = 0; |
39 | int viewport_line = 0; | 39 | int viewport_line = 0; |
40 | 40 | ||
41 | static int tag_recursion_level = 0; | ||
42 | |||
41 | #ifdef ROCKBOX | 43 | #ifdef ROCKBOX |
42 | static skin_callback callback = NULL; | 44 | static skin_callback callback = NULL; |
43 | static void* callback_data; | 45 | static void* callback_data; |
@@ -121,6 +123,8 @@ static struct skin_element* skin_parse_viewport(const char** document) | |||
121 | struct skin_element* root = NULL; | 123 | struct skin_element* root = NULL; |
122 | struct skin_element* last = NULL; | 124 | struct skin_element* last = NULL; |
123 | struct skin_element* retval = NULL; | 125 | struct skin_element* retval = NULL; |
126 | |||
127 | tag_recursion_level = 0; | ||
124 | 128 | ||
125 | retval = skin_alloc_element(); | 129 | retval = skin_alloc_element(); |
126 | if (!retval) | 130 | if (!retval) |
@@ -467,6 +471,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
467 | int req_args; /* To mark when we enter optional arguments */ | 471 | int req_args; /* To mark when we enter optional arguments */ |
468 | 472 | ||
469 | int optional = 0; | 473 | int optional = 0; |
474 | tag_recursion_level++; | ||
470 | 475 | ||
471 | /* Checking the tag name */ | 476 | /* Checking the tag name */ |
472 | tag_name[0] = cursor[0]; | 477 | tag_name[0] = cursor[0]; |
@@ -567,7 +572,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
567 | 572 | ||
568 | cursor = bookmark; /* Restoring the cursor */ | 573 | cursor = bookmark; /* Restoring the cursor */ |
569 | element->params_count = num_args; | 574 | element->params_count = num_args; |
570 | element->params = skin_alloc_params(num_args); | 575 | element->params = skin_alloc_params(num_args, tag_recursion_level<=1); |
571 | if (!element->params) | 576 | if (!element->params) |
572 | return 0; | 577 | return 0; |
573 | 578 | ||
@@ -712,6 +717,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
712 | } | 717 | } |
713 | #endif | 718 | #endif |
714 | *document = cursor; | 719 | *document = cursor; |
720 | tag_recursion_level--; | ||
715 | 721 | ||
716 | return 1; | 722 | return 1; |
717 | } | 723 | } |
@@ -1014,11 +1020,11 @@ struct skin_element* skin_alloc_element() | |||
1014 | * enough for any tag. params should be used straight away by the callback | 1020 | * enough for any tag. params should be used straight away by the callback |
1015 | * so this is safe. | 1021 | * so this is safe. |
1016 | */ | 1022 | */ |
1017 | struct skin_tag_parameter* skin_alloc_params(int count) | 1023 | struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params) |
1018 | { | 1024 | { |
1019 | #ifdef ROCKBOX | 1025 | #ifdef ROCKBOX |
1020 | static struct skin_tag_parameter params[MAX_TAG_PARAMS]; | 1026 | static struct skin_tag_parameter params[MAX_TAG_PARAMS]; |
1021 | if (count <= MAX_TAG_PARAMS) | 1027 | if (use_shared_params && count <= MAX_TAG_PARAMS) |
1022 | { | 1028 | { |
1023 | memset(params, 0, sizeof(params)); | 1029 | memset(params, 0, sizeof(params)); |
1024 | return params; | 1030 | return params; |