From 8a146226c82403cef454e33a156c1d929575c504 Mon Sep 17 00:00:00 2001
From: Phil Costin <philcostin@hotmail.com>
Date: Sat, 13 Jun 2015 23:28:06 +0100
Subject: [PATCH] When realloc(address, size) returns NULL, address must be
freed manually.
---
src/add-ons/kernel/network/stack/interfaces.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/add-ons/kernel/network/stack/interfaces.cpp b/src/add-ons/kernel/network/stack/interfaces.cpp
index 20b4110..b9de8a6 100644
a
|
b
|
InterfaceAddress::Prepare(sockaddr** _address, size_t size)
|
410 | 410 | sockaddr* address = *_address; |
411 | 411 | |
412 | 412 | if (address == NULL || size > address->sa_len) { |
413 | | address = (sockaddr*)realloc(address, size); |
414 | | if (address == NULL) |
| 413 | sockaddr *resized = (sockaddr*)realloc(address, size); |
| 414 | |
| 415 | if (resized == NULL) { |
| 416 | free(address); |
415 | 417 | return NULL; |
| 418 | } else { |
| 419 | address = resized; |
| 420 | } |
416 | 421 | } |
417 | 422 | |
418 | 423 | address->sa_len = size; |