{"thread":{"id":"2387","subject":"[PATCH] Small bugfixes for http-push.c","startedAt":"2005-11-07T18:23:11Z","lastAt":"2005-11-07T18:23:11Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"11265","messageId":"Pine.LNX.4.63.0511071918520.14111@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2387","inReplyTo":null,"subject":"[PATCH] Small bugfixes for http-push.c","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-07T18:23:11Z","receivedAt":"2005-11-07T18:23:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis patch fixes three things:\n\n- older libexpat does not know about enum XML_Status\n- as in my patch for http-fetch, do not rely on a curl result in\n\tfree()d data\n- calloc the new_lock structure\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tI verified in a small scale test that it works now. The buglets\n\tshowed only on my iBook, not on any Linux box I tried.\n\n\tThe calloc'ing of the new_lock structure is necessary, because\n\tactivelock_cdata() relies on several members being 0 until\n\tset by start_activelock_element().\n\n\tThe problem I was experiencing with a crash in \n\tcleanup_multi_handle() was due to the curl result not being\n\tinterpreted correctly.\n\n\tUnfortunately, valgrind does not work on macosx, so it could\n\tnot help me.\n\n\tNote: http-push shares a lot of code with http-fetch. It might\n\tbe a good idea to refactor them (after some more out-ironing).\n\n http-push.c |   14 ++++++++++++--\n 1 files changed, 12 insertions(+), 2 deletions(-)\ndiff --git a/http-push.c b/http-push.c\nindex c10067c..5532d02 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -28,6 +28,15 @@ static const char http_push_usage[] =\n #define NO_CURL_EASY_DUPHANDLE\n #endif\n \n+#ifndef XML_STATUS_OK\n+enum XML_Status {\n+  XML_STATUS_OK = 1,\n+  XML_STATUS_ERROR = 0\n+};\n+#define XML_STATUS_OK    1\n+#define XML_STATUS_ERROR 0\n+#endif\n+\n #define RANGE_HEADER_SIZE 30\n \n /* DAV method names and request body templates */\n@@ -728,11 +737,12 @@ void process_curl_messages(void)\n \t\t\t       slot->curl != curl_message->easy_handle)\n \t\t\t\tslot = slot->next;\n \t\t\tif (slot != NULL) {\n+\t\t\t\tint curl_result = curl_message->data.result;\n \t\t\t\tcurl_multi_remove_handle(curlm, slot->curl);\n \t\t\t\tactive_requests--;\n \t\t\t\tslot->done = 1;\n \t\t\t\tslot->in_use = 0;\n-\t\t\t\tslot->curl_result = curl_message->data.result;\n+\t\t\t\tslot->curl_result = curl_result;\n \t\t\t\tcurl_easy_getinfo(slot->curl,\n \t\t\t\t\t\t  CURLINFO_HTTP_CODE,\n \t\t\t\t\t\t  &slot->http_code);\n@@ -1230,7 +1240,7 @@ struct active_lock *lock_remote(char *fi\n \tin_buffer.posn = 0;\n \tin_buffer.buffer = in_data;\n \n-\tnew_lock = xmalloc(sizeof(*new_lock));\n+\tnew_lock = xcalloc(1, sizeof(*new_lock));\n \tnew_lock->owner = NULL;\n \tnew_lock->token = NULL;\n \tnew_lock->timeout = -1;\n"}]}