Skip to content

Commit 3150740

Browse files
authored
Merge pull request #3392 from amezin/macaddr-resource-leak
Fix memory/socket leak in `UniqueId::ethernetMacAddress()`
2 parents f64ea2a + a17193f commit 3150740

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/unique_id.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ std::string UniqueId::ethernetMacAddress() {
134134
(unsigned char)LLADDR(sdl)[3],
135135
(unsigned char)LLADDR(sdl)[4],
136136
(unsigned char)LLADDR(sdl)[5]);
137-
goto end;
137+
break;
138138
}
139139
}
140140

@@ -177,7 +177,7 @@ std::string UniqueId::ethernetMacAddress() {
177177
(unsigned char)ifr->ifr_addr.sa_data[4],
178178
(unsigned char)ifr->ifr_addr.sa_data[5]);
179179

180-
goto end;
180+
break;
181181
}
182182
}
183183
close(sock);
@@ -219,17 +219,14 @@ std::string UniqueId::ethernetMacAddress() {
219219
(unsigned char)pAdapter->Address[3],
220220
(unsigned char)pAdapter->Address[4],
221221
(unsigned char)pAdapter->Address[5]);
222-
goto end;
222+
break;
223223
}
224224
pAdapter = pAdapter->Next;
225225
}
226226

227227
free(pAdapterInfo);
228228
#endif
229229

230-
#if defined(__linux__) || defined(__gnu_linux__) || defined(DARWIN) || defined(WIN32)
231-
end:
232-
#endif
233230
return std::string(reinterpret_cast<const char *>(mac));
234231
#if defined(__linux__) || defined(__gnu_linux__) || defined(DARWIN) || defined(WIN32)
235232
failed:

0 commit comments

Comments
 (0)