--- tempstorage/TemporaryStorage.py~	2004-07-09 07:41:03.000000000 +0200
+++ tempstorage/TemporaryStorage.py	2005-01-07 22:16:12.000000000 +0100
@@ -266,7 +266,9 @@
         while roids:
             roid = roids.pop(0)
             # decrement refcnt:
-            rc=referenceCount_get(roid, 0)
+            # DM 2005-01-07: decrement *before* you make the test!
+            # rc=referenceCount_get(roid, 0)
+            rc=referenceCount_get(roid, 0) - 1
             if rc==0:
                 self._takeOutGarbage(roid)
             elif rc < 0:
@@ -275,7 +277,9 @@
                     (ReferenceCountError.__doc__,`roid`,rc)
                     )
             else:
-                referenceCount[roid] = rc - 1
+                # DM 2005-01-07: decremented *before* the test! see above
+                #referenceCount[roid] = rc - 1
+                referenceCount[roid] = rc
         try: del self._oreferences[oid]
         except: pass
 
