diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-12-09 22:06:38 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-12-09 22:06:38 +0000 |
commit | 8a5ad119bff89ab0f17b64efbb2b5b5ec0074efe (patch) | |
tree | cdf3f52c7d635546e5176e93700eb39331a85b61 /epan | |
parent | 056e30ad8b8a8e5b6b3e3ecfcc94a31611bc07d6 (diff) |
if passed a NULL string, make se_strdup() return the static string
"<NULL>" 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
Diffstat (limited to 'epan')
-rw-r--r-- | epan/emem.c | 10 |
1 files changed, 9 insertions, 1 deletions
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 "<NULL>" 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 "<NULL>"; + } + + len = strlen(src); dst = strncpy(se_alloc(len+1), src, len); dst[len] = '\0'; |