diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-06-04 13:37:10 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-06-08 11:35:06 -0400 |
commit | a9ca9d08ce562000b4aa155c54898763125eb7e3 (patch) | |
tree | 4ae4d8a600a2b5d718505da77c0f0e400e1fcf44 | |
parent | 23cc430238d6a0303e09bc00bd8c0c3f91f437da (diff) | |
download | sssd-a9ca9d08ce562000b4aa155c54898763125eb7e3.tar.gz sssd-a9ca9d08ce562000b4aa155c54898763125eb7e3.tar.xz sssd-a9ca9d08ce562000b4aa155c54898763125eb7e3.zip |
Fix invalid pointer error in ldb_debug_messages
-rw-r--r-- | server/util/debug.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/server/util/debug.c b/server/util/debug.c index f7f89f5c7..d6a98e29a 100644 --- a/server/util/debug.c +++ b/server/util/debug.c @@ -12,9 +12,16 @@ void debug_fn(const char *format, ...) { va_list ap; char *s = NULL; + int ret; va_start(ap, format); - vasprintf(&s, format, ap); + + ret = vasprintf(&s, format, ap); + if (ret < 0) { + /* ENOMEM */ + return; + } + va_end(ap); /*write(state.fd, s, strlen(s));*/ @@ -26,6 +33,9 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { int loglevel = -1; + int ret; + char * message = NULL; + switch(level) { case LDB_DEBUG_FATAL: loglevel = 0; @@ -41,5 +51,12 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level, break; } - DEBUG(loglevel, (fmt, ap)); + ret = vasprintf(&message, fmt, ap); + if (ret < 0) { + /* ENOMEM */ + return; + } + + DEBUG(loglevel, (message)); + free(message); } |