Fix segfault in prt-cache

Co-authored-by: Alexandr Savca <alexandr.savca89@gmail.com>
This commit is contained in:
Tim Biermann 2022-02-27 22:30:23 +01:00
parent da6bfb0a60
commit 8bc31c0745
1 changed files with 6 additions and 1 deletions

View File

@ -1806,6 +1806,11 @@ void PrtGet::ls()
if ( p ) {
string dirname = p->path() + "/" + p->name();
DIR* dir = opendir(dirname.c_str());
if (dir == NULL) {
cerr << "Directory " << dirname << " not found" << endl;
m_returnValue = PG_GENERAL_ERROR;
return;
}
struct dirent* entry;
vector<string> files;
while ((entry = readdir(dir))) {
@ -1848,7 +1853,7 @@ void PrtGet::cat()
}
string file = p->path() + "/" + p->name() + "/" + fileName;
if (!printFile(file)) {
cerr << "File '" << *it << "' not found" << endl;
cerr << "File '" << fileName << "' not found" << endl;
m_returnValue = PG_GENERAL_ERROR;
return;
}