comparison src/util.c @ 9818:5206fb21e358

[gaim-migrate @ 10689] Thanks, Stu committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 22 Aug 2004 16:16:46 +0000
parents fe268cb602cb
children 4d17a945aab3
comparison
equal deleted inserted replaced
9817:5afa28c94201 9818:5206fb21e358
2614 /* If we can find a Content-Length header at all, try to sscanf it. 2614 /* If we can find a Content-Length header at all, try to sscanf it.
2615 * Response headers should end with at least \r\n, so sscanf is safe, 2615 * Response headers should end with at least \r\n, so sscanf is safe,
2616 * if we make sure that there is indeed a \n in our header. 2616 * if we make sure that there is indeed a \n in our header.
2617 */ 2617 */
2618 if (p && g_strstr_len(p, data_len - (p - data), "\n")) { 2618 if (p && g_strstr_len(p, data_len - (p - data), "\n")) {
2619 sscanf(p, "Content-Length: %ud", &content_len); 2619 sscanf(p, "Content-Length: %u", &content_len);
2620 gaim_debug_misc("parse_content_len", "parsed %d\n", content_len); 2620 gaim_debug_misc("parse_content_len", "parsed %u\n", content_len);
2621 } 2621 }
2622 2622
2623 return content_len; 2623 return content_len;
2624 } 2624 }
2625 2625
2739 g_free(gfud->webdata); 2739 g_free(gfud->webdata);
2740 gfud->webdata = NULL; 2740 gfud->webdata = NULL;
2741 2741
2742 /* In with the new. */ 2742 /* In with the new. */
2743 gfud->data_len = content_len; 2743 gfud->data_len = content_len;
2744 gfud->webdata = g_malloc(gfud->data_len); 2744 gfud->webdata = g_try_malloc(gfud->data_len);
2745 if (gfud->webdata == NULL) {
2746 gaim_debug_error("gaim_url_fetch", "Failed to allocate %u bytes: %s\n", gfud->data_len, strerror(errno));
2747 gaim_input_remove(gfud->inpa);
2748 close(sock);
2749 gfud->callback(gfud->user_data, NULL, 0);
2750 destroy_fetch_url_data(gfud);
2751 }
2745 } 2752 }
2746 else 2753 else
2747 gfud->newline = TRUE; 2754 gfud->newline = TRUE;
2748 2755
2749 return; 2756 return;