From b4c39f4e7c9d8b20afb615f00f1013b7fec69b91 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 20 Jul 2017 23:43:11 -0500 Subject: [PATCH] msi: Avoid a null pointer dereference. Signed-off-by: Zebediah Figura Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/msi/database.c | 5 +++++ dlls/msi/tests/db.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 34f8d045336..85e830677b2 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -778,6 +778,11 @@ static UINT MSI_DatabaseImport(MSIDATABASE *db, LPCWSTR folder, LPCWSTR file) lstrcatW( path, file ); data = msi_read_text_archive( path, &len ); + if (!data) + { + msi_free(path); + return ERROR_FUNCTION_FAILED; + } ptr = data; msi_parse_line( &ptr, &columns, &num_columns, &len ); diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 278b45f9580..4ea1f100241 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -2369,6 +2369,12 @@ static void test_msiimport(void) r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + r = MsiDatabaseImportA(hdb, CURR_DIR, NULL); + ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); + + r = MsiDatabaseImportA(hdb, CURR_DIR, "nonexistent"); + ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %d\n", r); + r = add_table_to_db(hdb, test_data); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);