From 56738e0440e1617a90b6b76e1b6eb355601a268a Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Sun, 30 Nov 2014 17:49:00 +0000 Subject: Prevent null pointer dereference in memset This is copied from Wine's deb274226783ab886bdb44876944e156757efe2b msi: Prevent call to memset with a null pointer in get_tablecolumns function. https://bugzilla.gnome.org/show_bug.cgi?id=740901 --- libmsi/table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmsi/table.c b/libmsi/table.c index 895d5e0..5c207e3 100644 --- a/libmsi/table.c +++ b/libmsi/table.c @@ -669,7 +669,7 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const char *szTableName, L /* Note: _Columns table doesn't have non-persistent data */ /* if maxcount is non-zero, assume it's exactly right for this table */ - memset( colinfo, 0, maxcount * sizeof(*colinfo) ); + if (colinfo) memset( colinfo, 0, maxcount * sizeof(*colinfo) ); count = table->row_count; for (i = 0; i < count; i++) { @@ -682,7 +682,7 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const char *szTableName, L /* check the column number is in range */ if (col < 1 || col > maxcount) { - g_critical("column %d out of range\n", col); + g_critical("column %d out of range (maxcount: %d)\n", col, maxcount); continue; } /* check if this column was already set */ -- cgit