Fix small memleaks in nis_passwd() and nis_group().

These only occur upon error.

Code Review:	https://reviews.freebsd.org/D1849
Reviewed by:	delphij

CID:	1016715
CID:	1016717
This commit is contained in:
Pedro F. Giffuni 2015-02-20 01:02:32 +00:00
parent b6c8f26052
commit a69a20fa13
2 changed files with 6 additions and 2 deletions

View File

@ -1173,8 +1173,10 @@ nis_group(void *retval, void *mdata, va_list ap)
* terminator, alignment padding, and one (char *)
* pointer for the member list terminator.
*/
if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *))
if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *)) {
free(result);
goto erange;
}
memcpy(buffer, result, resultlen);
buffer[resultlen] = '\0';
free(result);

View File

@ -1392,8 +1392,10 @@ nis_passwd(void *retval, void *mdata, va_list ap)
continue;
}
}
if (resultlen >= bufsize)
if (resultlen >= bufsize) {
free(result);
goto erange;
}
memcpy(buffer, result, resultlen);
buffer[resultlen] = '\0';
free(result);