Ignore:
Timestamp:
2010-05-23T14:52:41Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
ba3233c
Parents:
228fc18
Message:

Restructure Twitter error parser a bit, it fed a NULL pointer to the XML
parser sometimes (which fails safely but is a bad idea anyway).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    r228fc18 r3d93aed  
    122122{
    123123        static char *ret = NULL;
    124         struct xt_parser *xp;
     124        struct xt_parser *xp = NULL;
    125125        struct xt_node *node;
    126         char *err_s = NULL;
    127126       
    128127        g_free(ret);
    129128        ret = NULL;
    130129       
    131         xp = xt_new(NULL, NULL);
    132         xt_feed(xp, req->reply_body, req->body_size);
    133        
    134         if ((node = xt_find_node(xp->root, "hash")) &&
    135             (node = xt_find_node(node->children, "error")) &&
    136             node->text_len > 0)
    137                 err_s = node->text;
    138        
    139         if (err_s)
    140         {
    141                 ret = g_strdup_printf("%s (%s)", req->status_string, err_s);
     130        if (req->body_size > 0)
     131        {
     132                xp = xt_new(NULL, NULL);
     133                xt_feed(xp, req->reply_body, req->body_size);
     134               
     135                if ((node = xt_find_node(xp->root, "hash")) &&
     136                    (node = xt_find_node(node->children, "error")) &&
     137                    node->text_len > 0)
     138                {
     139                        ret = g_strdup_printf("%s (%s)", req->status_string, node->text);
     140                        xt_free(xp);
     141                        return ret;
     142                }
     143               
    142144                xt_free(xp);
    143                 return ret;
    144         }
    145         else
    146         {
    147                 return req->status_string;
    148         }
     145        }
     146       
     147        return req->status_string;
    149148}
    150149
Note: See TracChangeset for help on using the changeset viewer.