Windows: free pointer after last reference
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 17 Oct 2011 13:28:11 +0000 (09:28 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 25 Oct 2011 17:49:15 +0000 (10:49 -0700)
This is a superficial change but is being done for readability.
If given the choice of freeing memory and then testing the pointer
value or vice-versa, test the pointer value first.

Change-Id: I189851c265a257d433df111622837db1d706c054
Reviewed-on: http://gerrit.openafs.org/5626
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp

index 831cf24..d03c63d 100644 (file)
@@ -5962,14 +5962,14 @@ try_exit:
             // offset by the length of the server name
             //
 
-            AFSExFreePool( pwchBuffer);
-
             if( uniFullPathName.Length > 0 &&
                 pwchBuffer != (WCHAR *)((char *)uniFullPathName.Buffer - ulNameDifference))
             {
 
                 AFSExFreePool( uniFullPathName.Buffer);
             }
+
+            AFSExFreePool( pwchBuffer);
         }
     }
 
@@ -6482,14 +6482,14 @@ try_exit:
             // offset by the length of the server name
             //
 
-            AFSExFreePool( pwchBuffer);
-
             if( uniFullPathName.Length > 0 &&
                 pwchBuffer != (WCHAR *)((char *)uniFullPathName.Buffer - ulNameDifference))
             {
 
                 AFSExFreePool( uniFullPathName.Buffer);
             }
+
+            AFSExFreePool( pwchBuffer);
         }
     }