# HG changeset patch # User Adam Chlipala # Date 1295812799 18000 # Node ID 45bd58736bb263efbbe3d3941fc4ff9e2e7b5854 # Parent 5f4fee8a4dcd88350a90532de4678f6458931950 Fix issues with empty page buffers for tasks diff -r 5f4fee8a4dcd -r 45bd58736bb2 src/c/urweb.c --- a/src/c/urweb.c Sun Jan 23 11:18:24 2011 -0500 +++ b/src/c/urweb.c Sun Jan 23 14:59:59 2011 -0500 @@ -462,8 +462,10 @@ ctx->get_header = NULL; ctx->get_header_data = NULL; - uw_buffer_init(uw_headers_max, &ctx->outHeaders, 0); - uw_buffer_init(uw_page_max, &ctx->page, 0); + uw_buffer_init(uw_headers_max, &ctx->outHeaders, 1); + ctx->outHeaders.start[0] = 0; + uw_buffer_init(uw_page_max, &ctx->page, 1); + ctx->page.start[0] = 0; ctx->returning_indirectly = 0; uw_buffer_init(uw_heap_max, &ctx->heap, uw_min_heap); uw_buffer_init(uw_script_max, &ctx->script, 1); @@ -1498,10 +1500,11 @@ static void uw_writec_unsafe(uw_context ctx, char c) { *(ctx->page.front)++ = c; + *ctx->page.front = 0; } void uw_writec(uw_context ctx, char c) { - uw_check(ctx, 1); + uw_check(ctx, 2); uw_writec_unsafe(ctx, c); } @@ -3144,6 +3147,9 @@ if (ctx->transactionals[i].free) ctx->transactionals[i].free(ctx->transactionals[i].data, 0); + if (*ctx->page.front) + uw_writec(ctx, 0); + // Splice script data into appropriate part of page if (ctx->returning_indirectly || ctx->script_header[0] == 0) { char *start = strstr(ctx->page.start, "");