From 8a5ad119bff89ab0f17b64efbb2b5b5ec0074efe Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Fri, 9 Dec 2005 22:06:38 +0000 Subject: if passed a NULL string, make se_strdup() return the static string "" instead of dumping. This allows callers to not have to check if the string is NULL or not. This fixes bugs 614 615 617 620 621 and 623 svn path=/trunk/; revision=16752 --- epan/emem.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'epan') diff --git a/epan/emem.c b/epan/emem.c index 31fb671d97..4b0190c66b 100644 --- a/epan/emem.c +++ b/epan/emem.c @@ -361,10 +361,18 @@ void* se_alloc0(size_t size) { return memset(se_alloc(size),'\0',size); } +/* If str is NULL, just return the string "" so that the callers dont + * have to bother checking it. + */ gchar* se_strdup(const gchar* src) { - guint len = strlen(src); + guint len; gchar* dst; + if(!src){ + return ""; + } + + len = strlen(src); dst = strncpy(se_alloc(len+1), src, len); dst[len] = '\0'; -- cgit v1.2.3