Fix a segfault when specifying an invalid host.
authorL. Alberto Giménez <agimenez@sysvalve.es>
Thu, 3 Feb 2011 21:26:43 +0000 (22:26 +0100)
committerL. Alberto Giménez <agimenez@sysvalve.es>
Thu, 3 Feb 2011 21:26:43 +0000 (22:26 +0100)
If the --host argument did not contain a valid hostname to contact to, a
segmentation fault was raised because the return value from oauth_http_post and
oauth_http_get was not being properly checked.

bti.c

diff --git a/bti.c b/bti.c
index f6479f8..17a2a93 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -724,6 +724,11 @@ static int send_request(struct session *session)
                                free(req_url);
                }
 
+               if (!reply) {
+                       fprintf(stderr, "Error retrieving from URL (%s)\n", endpoint);
+                       return 1;
+               }
+
                if ((session->action != ACTION_UPDATE) &&
                                (session->action != ACTION_RETWEET))
                        parse_timeline(reply, session);