diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index 23e4e6fa02b3..eb288052c2c7 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -277,8 +277,10 @@ if_nametosdl(char *name) return(NULL); } - if ((ret_sdl = malloc(sdl->sdl_len)) == NULL) + if ((ret_sdl = malloc(sdl->sdl_len)) == NULL) { + free(buf); return(NULL); + } memcpy((caddr_t)ret_sdl, (caddr_t)sdl, sdl->sdl_len); free(buf);