tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH 1/3] Remove useless NULL checks before calling free(3) in gettext.c



On Sat, 23 May 2015, William Orr wrote:

---
src/lib/libintl/gettext.c | 54 ++++++++++++++++++-----------------------------
1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/src/lib/libintl/gettext.c b/src/lib/libintl/gettext.c
index 6591422..479b4be 100644
--- a/src/lib/libintl/gettext.c
+++ b/src/lib/libintl/gettext.c
@@ -661,12 +661,12 @@ free_sysdep_table(struct mosysdepstr_h **table, uint32_t nstring)
{
	uint32_t i;

+	if (! table)
+		return;
+
	for (i=0; i<nstring; i++) {
-		if (table[i]) {
-			if (table[i]->expanded)
-				free(table[i]->expanded);
-			free(table[i]);
-		}
+		free(table[i]->expanded);

Doesn't this line potentially dereference a NULL table[i] ?


+		free(table[i]);
	}
	free(table);
}

-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index