diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-09-24 00:25:32 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-09-24 00:25:32 +0100 |
commit | 6f55bec04d9dc076a8e815f51b93b2391d76f973 (patch) | |
tree | 09d143384fb385c6762d63ebf0a9f8134234285d /lib/xmltree.c | |
parent | a07a8c245e4bd5142e382f029513eb92f040ae6e (diff) |
xt_from_string() will return NULL if the string wasn't terminated properly.
Adding an extra layer of defense against truncated responses from Twitter.
But as long as the response from xt_from_string() isn't NULL-checked this
won't help much. So that's my next step. :-)
Diffstat (limited to 'lib/xmltree.c')
-rw-r--r-- | lib/xmltree.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/xmltree.c b/lib/xmltree.c index 91d256d2..3ecb2b93 100644 --- a/lib/xmltree.c +++ b/lib/xmltree.c @@ -265,15 +265,18 @@ void xt_cleanup( struct xt_parser *xt, struct xt_node *node, int depth ) struct xt_node *xt_from_string( const char *in, int len ) { struct xt_parser *parser; - struct xt_node *ret; + struct xt_node *ret = NULL; if( len == 0 ) len = strlen( in ); parser = xt_new( NULL, NULL ); xt_feed( parser, in, len ); - ret = parser->root; - parser->root = NULL; + if( parser->cur == NULL ) + { + ret = parser->root; + parser->root = NULL; + } xt_free( parser ); return ret; |