diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-08-15 16:07:29 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-08-15 16:07:29 +0000 |
commit | 7ada090e70d25937d27b2e93b0dab4d9d68c5d23 (patch) | |
tree | 6d1da099d6b621b442e7a775783c752be182b186 /avahi-common/malloc.c | |
parent | fe367caf27dd022258218a768da1ae2ddd246203 (diff) |
* 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
Diffstat (limited to 'avahi-common/malloc.c')
-rw-r--r-- | avahi-common/malloc.c | 10 |
1 files changed, 5 insertions, 5 deletions
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); |