]> sjero.net Git - wget/commitdiff
warc: Fix segfault if CDX record is not found.
authorGijs van Tulder <gvtulder@gmail.com>
Wed, 30 May 2012 21:00:04 +0000 (23:00 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 2 Jun 2012 12:26:18 +0000 (14:26 +0200)
src/ChangeLog
src/warc.c

index 7e16b17c472f481814eed0c71e865d00fb859832..9e74e474683e9f5bfd2ae9bda109f2876bf98cd3 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-30  Gijs van Tulder  <gvtulder@gmail.com>
+
+       * warc.c: Fix segfault if CDX record is not found.
+
 2011-05-26  Steven Schweda  <sms@antinode.info>
        * connect.c [HAVE_SYS_SOCKET_H]: Include <sys/socket.h>.
        [HAVE_SYS_SELECT_H]: Include <sys/select.h>.
index 24751dbf90d028471477aad0feb5af92f645b31d..92a49ef8a4ec98eef2bba955e8f4007212ca2462 100644 (file)
@@ -1001,10 +1001,10 @@ warc_find_duplicate_cdx_record (char *url, char *sha1_digest_payload)
 
   char *key;
   struct warc_cdx_record *rec_existing;
-  hash_table_get_pair (warc_cdx_dedup_table, sha1_digest_payload, &key,
-                       &rec_existing);
+  int found = hash_table_get_pair (warc_cdx_dedup_table, sha1_digest_payload,
+                                   &key, &rec_existing);
 
-  if (rec_existing != NULL && strcmp (rec_existing->url, url) == 0)
+  if (found && strcmp (rec_existing->url, url) == 0)
     return rec_existing;
   else
     return NULL;