]> git.saurik.com Git - apt.git/blobdiff - methods/rred.cc
merge from lp:~mvo/apt/mvo
[apt.git] / methods / rred.cc
index 1a18a381c803351dd46d56f846a4b8e0277fb794..849973e1a6405a8fa06a1f37546789344b194a99 100644 (file)
@@ -252,13 +252,20 @@ struct EdCommand {                                                                /*{{{*/
 RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From,           /*{{{*/
                                        FileFd &out_file, Hashes *hash) const {
 #ifdef _POSIX_MAPPED_FILES
-       MMap ed_cmds(Patch, MMap::ReadOnly);
+       MMap ed_cmds(MMap::ReadOnly);
        if (Patch.gzFd() != NULL) {
                unsigned long mapSize = Patch.Size();
-               DynamicMMap dyn(0, mapSize, 0);
-               gzread(Patch.gzFd(), dyn.Data(), mapSize);
-               ed_cmds = dyn;
-       }
+               DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0);
+               if (dyn->validData() == false) {
+                       delete dyn;
+                       return MMAP_FAILED;
+               }
+               dyn->AddSize(mapSize);
+               gzread(Patch.gzFd(), dyn->Data(), mapSize);
+               ed_cmds = *dyn;
+       } else
+               ed_cmds = MMap(Patch, MMap::ReadOnly);
+
        MMap in_file(From, MMap::ReadOnly);
 
        if (ed_cmds.Size() == 0 || in_file.Size() == 0)