ifconfig: fix double free fatal error in INET_sprint

Based on the patch by Zheng Junling <zhengjunling@huawei.com>
and Chen Gang <cg.chen@huawei.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2015-02-03 12:11:30 +01:00
parent 8e74adab01
commit a977778893

View File

@ -91,9 +91,9 @@ static const char* FAST_FUNC INET_sprint(struct sockaddr *sap, int numeric)
{ {
static char *buff; /* defaults to NULL */ static char *buff; /* defaults to NULL */
free(buff);
if (sap->sa_family == 0xFFFF || sap->sa_family == 0) if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
return "[NONE SET]"; return "[NONE SET]";
free(buff);
buff = INET_rresolve((struct sockaddr_in *) sap, numeric, 0xffffff00); buff = INET_rresolve((struct sockaddr_in *) sap, numeric, 0xffffff00);
return buff; return buff;
} }
@ -173,9 +173,9 @@ static const char* FAST_FUNC INET6_sprint(struct sockaddr *sap, int numeric)
{ {
static char *buff; static char *buff;
free(buff);
if (sap->sa_family == 0xFFFF || sap->sa_family == 0) if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
return "[NONE SET]"; return "[NONE SET]";
free(buff);
buff = INET6_rresolve((struct sockaddr_in6 *) sap, numeric); buff = INET6_rresolve((struct sockaddr_in6 *) sap, numeric);
return buff; return buff;
} }