summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kitt <steve@sk2.org>2014-11-30 17:49:00 +0000
committerMarc-André Lureau <marcandre.lureau@gmail.com>2014-11-30 20:39:34 +0100
commit56738e0440e1617a90b6b76e1b6eb355601a268a (patch)
treea50ee70b9700cb274fcac90f56ffe5c5a1363974
parented79cf41911bcddd2a2ce0edfbc3809627637460 (diff)
downloadmsitools-56738e0440e1617a90b6b76e1b6eb355601a268a.zip
msitools-56738e0440e1617a90b6b76e1b6eb355601a268a.tar.gz
msitools-56738e0440e1617a90b6b76e1b6eb355601a268a.tar.xz
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
-rw-r--r--libmsi/table.c4
1 files 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 */