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:
pfg 2015-02-20 01:02:32 +00:00
parent c0ae6c2127
commit aef2a88791
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);