diff options
author | Maximilian Schwerin <post@mschwerin.de> | 2007-12-27 14:25:28 +0000 |
---|---|---|
committer | Maximilian Schwerin <post@mschwerin.de> | 2007-12-27 14:25:28 +0000 |
commit | a2d20c60cd88481989316a8cedf8bd7d1e9be94a (patch) | |
tree | b8f14c9eed3c68c6704eb80c6676db743ace14d7 /src/xine-utils/xmllexer.c | |
parent | 84e2f56c6cc81e9bed8ba03b29a8c69aa7d08d89 (diff) | |
download | xine-lib-a2d20c60cd88481989316a8cedf8bd7d1e9be94a.tar.gz xine-lib-a2d20c60cd88481989316a8cedf8bd7d1e9be94a.tar.bz2 |
xmlparser: fix token buffer being too small
What this patch does is replace the token buffer of static size in
xml_parser_get_node with a malloced buffer. If the lexer notices, that it
needs more size it just increases the size of this buffer by factor two and
tries again. This may not be very elegant, but it works.
node_name and property_name are dynamically-sized too.
Diffstat (limited to 'src/xine-utils/xmllexer.c')
-rw-r--r-- | src/xine-utils/xmllexer.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c index 047dbb1a6..a77d6654a 100644 --- a/src/xine-utils/xmllexer.c +++ b/src/xine-utils/xmllexer.c @@ -123,7 +123,10 @@ void lexer_init(const char * buf, int size) { lprintf("buffer length %d\n", size); } -int lexer_get_token(char * tok, int tok_size) { +int lexer_get_token(char ** _tok, int * _tok_size) { + char *tok = *_tok; + int tok_size = *_tok_size; + int tok_pos = 0; int state = 0; char c; @@ -455,7 +458,15 @@ int lexer_get_token(char * tok, int tok_size) { /* pb */ if (tok_pos >= tok_size) { - lprintf("token buffer is too little\n"); + *_tok_size *= 2; + *_tok = realloc (*_tok, *_tok_size); + lprintf("token buffer is too small\n"); + lprintf("increasing buffer size to %d bytes\n", *_tok_size); + if (*_tok) { + return lexer_get_token (_tok, _tok_size); + } else { + return T_ERROR; + } } else { if (lexbuf_pos >= lexbuf_size) { /* Terminate the current token */ |