Fixed memory leaks in namesys and path.

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-12-08 06:48:38 -03:00
parent e69f10a68f
commit 84f24797f4
7 changed files with 70 additions and 38 deletions

View file

@ -87,7 +87,7 @@ int ipfs_path_resolve_path_components(Node ***nd, Context ctx, Resolver *s, char
// would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links
int ipfs_path_resolve_links(Node ***result, Context ctx, Node *ndd, char **names)
{
int err, idx = 0;
int err, idx = 0, l;
NodeLink *lnk;
Node *nd;
@ -115,9 +115,10 @@ int ipfs_path_resolve_links(Node ***result, Context ctx, Node *ndd, char **names
if (ErrPath[ErrNoLink]) {
free(ErrPath[ErrNoLink]);
}
ErrPath[ErrNoLink] = malloc(strlen(msg) + 1);
l = strlen(msg) + 1;
ErrPath[ErrNoLink] = malloc(l);
if (ErrPath[ErrNoLink]) {
strcpy(ErrPath[ErrNoLink], msg);
memcpy(ErrPath[ErrNoLink], msg, l);
}
free (*result);
return ErrNoLink;