Commit ff73b19a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

pstreamCloseAll: check for valid ids.

parent bd354eb2
#if defined(HAVE_CONFIG_H)
# include "config.h"
#include "config.h"
#endif
#include <stdarg.h>
......@@ -61,8 +61,11 @@ void cdiOpenError(int cdiErrno, const char *fmt, const char *path)
}
}
if ( _ExitOnError ) pstreamCloseAll();
if ( _ExitOnError ) exit(EXIT_FAILURE);
if ( _ExitOnError )
{
pstreamCloseAll();
exit(EXIT_FAILURE);
}
}
void cdoAbort(const char *fmt, ...)
......@@ -80,8 +83,11 @@ void cdoAbort(const char *fmt, ...)
reset_text_color(stderr);
fprintf(stderr, "\n");
if ( _ExitOnError ) pstreamCloseAll();
if ( _ExitOnError ) exit(EXIT_FAILURE);
if ( _ExitOnError )
{
pstreamCloseAll();
exit(EXIT_FAILURE);
}
}
......
......@@ -1742,13 +1742,18 @@ cdoInitialize(void *argument)
processDefArgument(argument);
}
void pstreamCloseAll()
void
pstreamCloseAll()
{
for(auto pstream_iter : _pstream_map)
for (auto pstream_iter : _pstream_map)
{
if(PSTREAM_Debug)
Message("Close file %s id %d", pstream_iter.second.m_name.c_str(), pstream_iter.second.m_fileID);
streamClose(pstream_iter.second.m_fileID);
if ( pstream_iter.second.m_fileID != CDI_UNDEFID )
{
if (PSTREAM_Debug)
Message("Close file %s id %d", pstream_iter.second.m_name.c_str(), pstream_iter.second.m_fileID);
streamClose(pstream_iter.second.m_fileID);
}
}
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment