Commit 784d509f authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fix potential overwriting of errno.

* va_start, printf, fprintf, vfprintf, va_end are all candidates.
parent 2e7067bd
......@@ -27,6 +27,7 @@ void SysError_(const char *caller, const char *fmt, ...)
void SysError_(const char *caller, const char *fmt, ...)
{
va_list args;
int saved_errno = errno;
va_start(args, fmt);
......@@ -37,8 +38,11 @@ void SysError_(const char *caller, const char *fmt, ...)
va_end(args);
if ( errno )
perror("System error message ");
if ( saved_errno )
{
errno = saved_errno;
perror("System error message");
}
exit(EXIT_FAILURE);
}
......
......@@ -78,8 +78,6 @@ static const resOps gridOps = {
gridTxCode
};
static const struct gridVirtTable serialGridVtable;
static int GRID_Debug = 0; /* If set to 1, debugging */
grid_t *gridID2Ptr(int gridID)
......@@ -163,7 +161,7 @@ void grid_init(grid_t *gridptr)
gridptr->ystdname = NULL;
memset(gridptr->uuid, 0, CDI_UUID_SIZE);
gridptr->name = NULL;
gridptr->vtable = &serialGridVtable;
gridptr->vtable = &cdiGridVtable;
gridptr->extraData = NULL;
}
......@@ -4697,7 +4695,7 @@ int varDefGrid(int vlistID, const grid_t *grid, int mode)
return (gridID);
}
static const struct gridVirtTable serialGridVtable
const struct gridVirtTable cdiGridVtable
= {
.destroy = gridDestroyKernel,
.duplicateData = gridDuplicateData,
......
......@@ -104,6 +104,7 @@ struct grid_t {
void grid_init(grid_t *gridptr);
void grid_free(grid_t *gridptr);
grid_t *gridID2Ptr(int gridID);
extern const struct gridVirtTable cdiGridVtable;
unsigned cdiGridCount(void);
......
Supports Markdown
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