We have a relatively large code base for a Linux server application: several applications, dynamically linked libraries and loadable server modules. Most of these are written in C++11, but some in C99.
What approaches could one use to test whether the code properly handles memory allocation failures, e.g.malloc
/calloc
returning NULL
, operators new
and new[]
throwing std::bad_alloc
etc, including allocation failures from std::string::resize()
and such.
In the past, I've tried using memory allocation hooks to inject memory allocation failures into C applications, but I think these don't work for C++. What other options or approaches should I be looking at?
Aucun commentaire:
Enregistrer un commentaire