Author: j16sdiz
Date: 2009-04-06 06:01:29 +0000 (Mon, 06 Apr 2009)
New Revision: 26553

Modified:
   trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
   trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
Log:
Check for null before dereference, not after

Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2009-04-06 06:01:07 UTC (rev 26552)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2009-04-06 06:01:29 UTC (rev 26553)
@@ -33,7 +33,6 @@
 import freenet.node.SendableRequestSender;
 import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
-import freenet.support.SimpleFieldSet;
 import freenet.support.api.Bucket;
 import freenet.support.io.BucketTools;
 import freenet.support.io.NativeThread;
@@ -481,6 +480,10 @@
                                        } finally {
                                                block.copyBucket.free();
                                        }
+                                       if (b==null) {
+                                               Logger.error(this, "Asked to 
send empty block on "+SingleBlockInserter.this, new Exception("error"));
+                                               return false;
+                                       }
                                        final ClientKey key = b.getClientKey();
                                        if(block.persistent) {
                                        context.jobRunner.queue(new DBJob() {
@@ -503,12 +506,7 @@
                                                }, "Got URI");
                                                
                                        }
-                                       if(b != null)
-                                               core.realPut(b, 
req.cacheLocalRequests);
-                                       else {
-                                               Logger.error(this, "Asked to 
send empty block on "+SingleBlockInserter.this, new Exception("error"));
-                                               return false;
-                                       }
+                                       core.realPut(b, req.cacheLocalRequests);
                                } catch (LowLevelPutException e) {
                                        req.onFailure(e, context);
                                        if(logMINOR) Logger.minor(this, 
"Request failed: "+SingleBlockInserter.this+" for "+e);

Modified: trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java        
2009-04-06 06:01:07 UTC (rev 26552)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java        
2009-04-06 06:01:29 UTC (rev 26553)
@@ -1373,6 +1373,10 @@
                                        } finally {
                                                block.copyBucket.free();
                                        }
+                                       if (b==null) {
+                                               Logger.error(this, "Asked to 
send empty block on "+SplitFileInserterSegment.this, new Exception("error"));
+                                               return false;
+                                       }
                                        final ClientCHK key = (ClientCHK) 
b.getClientKey();
                                        final int num = block.blockNum;
                                        if(block.persistent) {
@@ -1396,12 +1400,7 @@
                                                }, "Got URI");
                                                
                                        }
-                                       if(b != null)
-                                               core.realPut(b, 
req.cacheLocalRequests);
-                                       else {
-                                               Logger.error(this, "Asked to 
send empty block on "+SplitFileInserterSegment.this, new Exception("error"));
-                                               return false;
-                                       }
+                                       core.realPut(b, req.cacheLocalRequests);
                                } catch (LowLevelPutException e) {
                                        req.onFailure(e, context);
                                        if(logMINOR) Logger.minor(this, 
"Request failed: "+SplitFileInserterSegment.this+" for "+e);

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

Reply via email to