fix potential access of NULL pointer

It could happen if delimiter is NULL. Currently the
only use is with non-NULL delimiter.
This commit is contained in:
Nedko Arnaudov 2012-11-17 15:36:00 +02:00
parent c2fc519d5c
commit 6b3524b6a6
1 changed files with 6 additions and 3 deletions

View File

@ -2,7 +2,7 @@
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2009,2010 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2009,2010,2012 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains implementation of the catdup() function
@ -185,8 +185,11 @@ char * catdup_array(const char ** array, const char * delimiter)
len = strlen(array[i]);
memcpy(p, array[i], len);
p += len;
memcpy(p, delimiter, delimiter_length);
p += delimiter_length;
if (delimiter_length > 0)
{
memcpy(p, delimiter, delimiter_length);
p += delimiter_length;
}
}
*p = 0;