diff --git a/.gitattributes b/.gitattributes
index 5fe7a63fa3ef85cd155de4e06afe9ca5b60f2ae9..e4b2c64a7e7a9eaa9cb0cc2e3081fea73a0e3241 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -378,7 +378,6 @@ testfont binary
 /src/fsort.c foreign_ident
 /src/fsort.h foreign_ident
 /src/fsort_template.h foreign_ident
-/src/gc.c foreign_ident
 /src/gc.h foreign_ident
 /src/global.h foreign_ident
 /src/hashtable.c foreign_ident
diff --git a/src/gc.c b/src/gc.c
index 1ae9fe970f949403200755dd50dd17ef6116231a..53a01586bd7c9ee99f76de3709a731c199c95801 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: gc.c,v 1.330 2008/10/12 21:49:56 mast Exp $
+|| $Id$
 */
 
 #include "global.h"
@@ -5511,6 +5511,11 @@ void f_count_memory (INT32 args)
       } while (m != &mc_complete);
     }
 
+    /* We've moved all the markers on mc_complete to the work queue,
+     * so we need to empty mc_complete in order to use it again for
+     * the next batch of indirect markers.
+     */
+    DL_MAKE_EMPTY(mc_complete);
     DL_MOVE (mc_indirect, mc_complete);
 
     TOGGLE_EXT_FLAGS();