diff options
author | Cristian RodrÃguez <cristian.rodriguez@opensuse.org> | 2010-12-28 21:10:31 -0300 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2011-01-05 13:13:48 +0000 |
commit | e2be7b92a6d46f02d8d682dd9e51bb494f41e92c (patch) | |
tree | f1509eafcb077e442b4d40a12af8a0c151e8b958 /dbus/dbus-memory.h | |
parent | 56d8d4f58ee60cd4f860a99a2dd47b3f636321b8 (diff) | |
download | dbus-e2be7b92a6d46f02d8d682dd9e51bb494f41e92c.tar.gz |
Annotate dbus_malloc*() functions with __attribute__ malloc and __attribute__ alloc_size
This improves optimization as well catches buffer overflows at compile time.
code like:
foo = dbus_malloc(2);
strcpy(foo, "epicfail");
will emit:
"warning ... will always overflow the destination buffer..."
Signed-off-by: Cristian RodrÃguez <cristian.rodriguez@opensuse.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=32710
Diffstat (limited to 'dbus/dbus-memory.h')
-rw-r--r-- | dbus/dbus-memory.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/dbus/dbus-memory.h b/dbus/dbus-memory.h index ea28423c..4fd56bd6 100644 --- a/dbus/dbus-memory.h +++ b/dbus/dbus-memory.h @@ -38,10 +38,18 @@ DBUS_BEGIN_DECLS */ DBUS_EXPORT +DBUS_MALLOC +DBUS_ALLOC_SIZE(1) void* dbus_malloc (size_t bytes); + DBUS_EXPORT +DBUS_MALLOC +DBUS_ALLOC_SIZE(1) void* dbus_malloc0 (size_t bytes); + DBUS_EXPORT +DBUS_MALLOC +DBUS_ALLOC_SIZE(2) void* dbus_realloc (void *memory, size_t bytes); DBUS_EXPORT |