8007606: Handle realloc() failure in unix/native/libnet/net_util_md.c correctly

Reviewed-by: clanger, mbaesken
This commit is contained in:
Ivan Gerasimov 2019-01-16 10:12:58 -08:00
parent b9333e1d81
commit f31819f7c5

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -647,6 +647,7 @@ static void initLocalIfs () {
unsigned char staddr [16];
char ifname [33];
struct localinterface *lif=0;
struct localinterface *localifsTemp;
int index, x1, x2, x3;
unsigned int u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,ua,ub,uc,ud,ue,uf;
@ -675,13 +676,17 @@ static void initLocalIfs () {
staddr[15] = (unsigned char)uf;
nifs ++;
if (nifs > localifsSize) {
localifs = (struct localinterface *) realloc (
localifsTemp = (struct localinterface *) realloc(
localifs, sizeof (struct localinterface)* (localifsSize+5));
if (localifs == 0) {
if (localifsTemp == 0) {
free(localifs);
localifs = 0;
localifsSize = 0;
nifs = 0;
fclose (f);
fclose(f);
return;
}
localifs = localifsTemp;
lif = localifs + localifsSize;
localifsSize += 5;
} else {