utils: avoid segfault when calling osmo_strlcpy(src=NULL)

Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413
This commit is contained in:
Neels Hofmeyr 2017-10-25 04:16:45 +02:00
parent b48e82ca9e
commit bcf9f23456
1 changed files with 1 additions and 1 deletions

View File

@ -372,7 +372,7 @@ uint8_t *osmo_encode_big_endian(uint64_t value, size_t data_len)
*/
size_t osmo_strlcpy(char *dst, const char *src, size_t siz)
{
size_t ret = strlen(src);
size_t ret = src ? strlen(src) : 0;
if (siz) {
size_t len = (ret >= siz) ? siz - 1 : ret;