![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsCanary.h>
Public Member Functions | |
| Canary ()=default | |
| ~Canary () | |
Static Public Member Functions | |
| static const UChar * | Error (const Canary *c) |
| static bool | IsValid (const Canary *c) |
| static const UChar * | LogError (const Canary *c) |
Canary class to detect memory corruption in instable environments.
Some libraries or operating systems associate a "user-pointer" to an event or some equivalent concept. This user-pointer usually is a user-allocated data structure. It is passed back to the application by the library or operating system at some point in the future.
The application must ensure that the user-allocated structure remains valid as long as the user-pointer is stored in the library or operating system. Otherwise, the application may receive the address of a structure which is no longer valid.
In some cases, it is complicated to understand how long this user pointer is stored. To track potential errors in our interpretation of the various libraries or operating systems logics, we use some internal consistency checks using canaries, values which are altered when the structure is no longer valid.
User-defined data structures which are used as user-pointer for external libraries or operating systems should use a Canary field as first field.
|
default |
Constructor with a "good" default value.
|
inline |
The destructor sets a "bad" canary to detect use-after-free in case of incorrect order of usage.
Check that a Canary pointer is valid, get and log an error message on standard error.
| [in] | c | The address of something that is expected to be a valid Canary. |
|
inlinestatic |