From 7ada090e70d25937d27b2e93b0dab4d9d68c5d23 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Aug 2005 16:07:29 +0000 Subject: * fix a bad memory access bug in avahi_strndup() * some small optimizations to call gettimeofday() less often * fix dbus-watch-glue to call dbus_connection_dispatch() git-svn-id: file:///home/lennart/svn/public/avahi/trunk@333 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-common/malloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'avahi-common/malloc.c') diff --git a/avahi-common/malloc.c b/avahi-common/malloc.c index 018a0c0..9b0e22e 100644 --- a/avahi-common/malloc.c +++ b/avahi-common/malloc.c @@ -169,16 +169,16 @@ char *avahi_strdup(const char *s) { char *avahi_strndup(const char *s, size_t max) { char *r; size_t size; + const char *p; if (!s) return NULL; - size = strlen(s); - - if (size > max) - size = max; + for (p = s, size = 0; + size < max && *p; + p++, size++); - if (!(r = avahi_malloc(size+1))) + if (!(r = avahi_new(char, size+1))) return NULL; memcpy(r, s, size); -- cgit