Author: toad
Date: 2009-03-20 23:01:21 +0000 (Fri, 20 Mar 2009)
New Revision: 26128

Modified:
   branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
Log:
Move freeing the original data after compression inside onCompressedInner, as 
saces points out we use block.getData() inside onCompressedInner(), so freeing 
before we enter it can cause problems!


Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java      
2009-03-20 22:59:47 UTC (rev 26127)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java      
2009-03-20 23:01:21 UTC (rev 26128)
@@ -156,13 +156,6 @@
                        return;
                }
                if(persistent) container.activate(block, 1);
-               if(output.bestCodec != null) {
-                       if(freeData) {
-                               block.getData().free();
-                               block.getData().removeFrom(container);
-                       }
-                       block.nullData();
-               }
                try {
                        onCompressedInner(output, container, context);
                } catch (InsertException e) {
@@ -201,6 +194,11 @@
                if(bestCodec != null) {
                        if(logMINOR) Logger.minor(this, "The best compression 
algorithm is "+bestCodec+ " we have gained"+ 
(100-(bestCompressedDataSize*100/origSize)) +"% ! 
("+origSize+'/'+bestCompressedDataSize+')');
                        shouldFreeData = true; // must be freed regardless of 
whether the original data was to be freed
+                       if(freeData) {
+                               block.getData().free();
+                               block.getData().removeFrom(container);
+                       }
+                       block.nullData();
                } else {
                        data = block.getData();
                }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to