Prechádzať zdrojové kódy

HDFS-596. Fix memory leak in hdfsFreeFileInfo() for libhdfs.
(Zhang Bingjun via dhruba)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-203@1098819 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 rokov pred
rodič
commit
bcd3746e8d
2 zmenil súbory, kde vykonal 10 pridanie a 1 odobranie
  1. 3 0
      CHANGES.txt
  2. 7 1
      src/c++/libhdfs/hdfs.c

+ 3 - 0
CHANGES.txt

@@ -1688,6 +1688,9 @@ Release 0.20.2 - Unreleased
     HDFS-579. Fix DfsTask to follow the semantics of 0.19, regarding non-zero
     return values as failures. (Christian Kunz via cdouglas)
 
+    HDFS-596. Fix memory leak in hdfsFreeFileInfo() for libhdfs.
+    (Zhang Bingjun via dhruba)
+
 Release 0.20.1 - 2009-09-01
 
   INCOMPATIBLE CHANGES

+ 7 - 1
src/c++/libhdfs/hdfs.c

@@ -2022,12 +2022,18 @@ hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path)
 
 void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries)
 {
-    //Free the mName
+    //Free the mName, mOwner, and mGroup
     int i;
     for (i=0; i < numEntries; ++i) {
         if (hdfsFileInfo[i].mName) {
             free(hdfsFileInfo[i].mName);
         }
+        if (hdfsFileInfo[i].mOwner) {
+            free(hdfsFileInfo[i].mOwner);
+        }
+        if (hdfsFileInfo[i].mGroup) {
+            free(hdfsFileInfo[i].mGroup);
+        }
     }
 
     //Free entire block