diff --git a/src/warc.c b/src/warc.c index 5ebd04d7..2eb74966 100644 --- a/src/warc.c +++ b/src/warc.c @@ -1364,6 +1364,7 @@ warc_write_cdx_record (const char *url, const char *timestamp_str, char timestamp_str_cdx[15]; char offset_string[MAX_INT_TO_STRING_LEN(off_t)]; const char *checksum; + char *tmp_location = NULL; memcpy (timestamp_str_cdx , timestamp_str , 4); /* "YYYY" "-" */ memcpy (timestamp_str_cdx + 4, timestamp_str + 5, 2); /* "mm" "-" */ @@ -1382,18 +1383,19 @@ warc_write_cdx_record (const char *url, const char *timestamp_str, if (mime_type == NULL || strlen(mime_type) == 0) mime_type = "-"; if (redirect_location == NULL || strlen(redirect_location) == 0) - redirect_location = "-"; + tmp_location = strdup ("-"); else - redirect_location = url_escape(redirect_location); + tmp_location = url_escape(redirect_location); number_to_string (offset_string, offset); /* Print the CDX line. */ fprintf (warc_current_cdx_file, "%s %s %s %s %d %s %s - %s %s %s\n", url, timestamp_str_cdx, url, mime_type, response_code, checksum, - redirect_location, offset_string, warc_current_filename, + tmp_location, offset_string, warc_current_filename, response_uuid); fflush (warc_current_cdx_file); + free (tmp_location); return true; }