Check result of malloc.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2457 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -40,17 +40,23 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
void
|
int
|
||||||
copy_general_string (const general_string *from, general_string *to)
|
copy_general_string (const general_string *from, general_string *to)
|
||||||
{
|
{
|
||||||
*to = malloc(strlen(*from) + 1);
|
*to = malloc(strlen(*from) + 1);
|
||||||
|
if(*to == NULL)
|
||||||
|
return ENOMEM;
|
||||||
strcpy(*to, *from);
|
strcpy(*to, *from);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
copy_octet_string (const octet_string *from, octet_string *to)
|
copy_octet_string (const octet_string *from, octet_string *to)
|
||||||
{
|
{
|
||||||
to->length = from->length;
|
to->length = from->length;
|
||||||
to->data = malloc(to->length);
|
to->data = malloc(to->length);
|
||||||
|
if(to->data == NULL)
|
||||||
|
return ENOMEM;
|
||||||
memcpy(to->data, from->data, to->length);
|
memcpy(to->data, from->data, to->length);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user