dbus/test/test-segfault.c
Ralf Habacker 3e8423d299 test-segfault: Fix build error caused by a null pointer dereference warning
Only do the deliberate crash via undefined behaviour (which the compiler
is quite right to warn us about!) if raise() isn't available.

The pointer needs to be volatile otherwise the compiler is free to remove
the store.

Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275
Reviewed-by: Simon McVittie <smcv@collabora.com>
2022-04-21 13:54:23 +01:00

25 lines
359 B
C

/* This is simply a process that segfaults */
#include <config.h>
#include <stdlib.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#include "disable-crash-handling.h"
int
main (int argc, char **argv)
{
_dbus_disable_crash_handling ();
#ifdef HAVE_RAISE
raise (SIGSEGV);
#else
{
volatile char *p = NULL;
*p = 'a';
}
#endif
return 0;
}