Better handle low memory conditions.

remotes/origin/master-1.1.x
Victor Julien 16 years ago
parent 57f5327d56
commit 22f770f3bf

@ -943,10 +943,10 @@ SCLogInitData *SCLogAllocLogInitData(void)
{
SCLogInitData *sc_lid = NULL;
if ( (sc_lid = malloc(sizeof(SCLogInitData))) == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered initializing the logging subsytem. Out of memory. Exiting...");
exit(EXIT_FAILURE);
}
/* not using SCMalloc here because if it fails we can't log */
if ( (sc_lid = malloc(sizeof(SCLogInitData))) == NULL)
return NULL;
memset(sc_lid, 0, sizeof(SCLogInitData));
return sc_lid;

@ -154,6 +154,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
#define SCFree(a) free((a))
#endif
#if 0
#define SCMalloc(a) ({ \
void *ptrmem = NULL; \
\
@ -214,6 +215,11 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
} \
(void*)ptrmem; \
})
#endif
#define SCMalloc malloc
#define SCRealloc realloc
#define SCCalloc calloc
#define SCStrdup strdup
#define SCFree(a) ({ \
free(a); \

Loading…
Cancel
Save