diff options
Diffstat (limited to 'src/common/strlib.c')
-rw-r--r-- | src/common/strlib.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c index 4f204a768..c0a6238f9 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -310,6 +310,12 @@ char* safestrncpy(char* dst, const char* src, size_t n) return ret; } +/// doesn't crash on null pointer +size_t safestrnlen(const char* string, size_t maxlen) +{ + return ( string != NULL ) ? strnlen(string, maxlen) : 0; +} + ///////////////////////////////////////////////////////////////////// // StringBuf - dynamic string |