We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d5b6f3 commit 2708a5bCopy full SHA for 2708a5b
libdnet-stripped/src/intf-win32.c
@@ -92,15 +92,23 @@ _ifcombo_type(const char *device)
92
static void
93
_ifcombo_add(struct ifcombo *ifc, DWORD ipv4_idx, DWORD ipv6_idx)
94
{
95
+ void* pmem = NULL;
96
if (ifc->cnt == ifc->max) {
97
if (ifc->idx) {
98
ifc->max *= 2;
- ifc->idx = realloc(ifc->idx,
99
+ pmem = realloc(ifc->idx,
100
sizeof(ifc->idx[0]) * ifc->max);
101
} else {
102
ifc->max = 8;
- ifc->idx = malloc(sizeof(ifc->idx[0]) * ifc->max);
103
+ pmem = malloc(sizeof(ifc->idx[0]) * ifc->max);
104
}
105
+ if (!pmem) {
106
+ /* malloc or realloc failed. Restore state.
107
+ * TODO: notify caller. */
108
+ ifc->max = ifc->cnt;
109
+ return;
110
+ }
111
+ ifc->idx = pmem;
112
113
ifc->idx[ifc->cnt].ipv4 = ipv4_idx;
114
ifc->idx[ifc->cnt].ipv6 = ipv6_idx;
0 commit comments