X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/ef38181605be2f7131bed9865d965300339389b5..78485ab210b815c21ce55cb0cecb834ba5158e18:/apt-pkg/contrib/cdromutl.cc diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index cf1c0c29b..821e6d688 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -206,8 +205,11 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) Hash.Add(Dir->d_name); }; - if (chdir(StartDir.c_str()) != 0) - return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + if (chdir(StartDir.c_str()) != 0) { + _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); + closedir(D); + return false; + } closedir(D); // Some stats from the fsys @@ -236,8 +238,8 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) } /*}}}*/ -// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ -char* FindMountPointForDevice(const char *devnode) +// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ +string FindMountPointForDevice(const char *devnode) { char buf[255]; char *out[10]; @@ -254,14 +256,16 @@ char* FindMountPointForDevice(const char *devnode) while ( fgets(buf, sizeof(buf), f) != NULL) { if (strncmp(buf, devnode, strlen(devnode)) == 0) { if(TokSplitString(' ', buf, out, 10)) - return strdup(out[1]); + { + fclose(f); + return string(out[1]); + } } } fclose(f); } } - return NULL; + return string(); } - - + /*}}}*/