diff --git a/dlls/msi/table.c b/dlls/msi/table.c index a8f0f40..572cad6 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -2054,6 +2054,9 @@ static UINT TABLE_sort(struct tagMSIVIEW *view, column_info *columns) if (r != ERROR_SUCCESS) return r; + if (rows == 0) + return ERROR_SUCCESS; + order = msi_alloc_zero(sizeof(MSIORDERINFO) + sizeof(UINT) * cols); if (!order) return ERROR_OUTOFMEMORY; diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index ac15d24..aee2e80 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -4777,6 +4777,10 @@ static void test_order(void) hdb = create_db(); ok(hdb, "failed to create db\n"); + query = "CREATE TABLE `Empty` ( `A` SHORT NOT NULL PRIMARY KEY `A`)"; + r = run_query(hdb, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + query = "CREATE TABLE `Mesa` ( `A` SHORT NOT NULL, `B` SHORT, `C` SHORT PRIMARY KEY `A`)"; r = run_query(hdb, 0, query); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -4964,6 +4968,18 @@ static void test_order(void) MsiViewClose(hview); MsiCloseHandle(hview); + + query = "SELECT * FROM `Empty` ORDER BY `A`"; + r = MsiDatabaseOpenView(hdb, query, &hview); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + r = MsiViewExecute(hview, 0); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + r = MsiViewFetch(hview, &hrec); + ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r); + + MsiViewClose(hview); + MsiCloseHandle(hview); MsiCloseHandle(hdb); } -- 1.5.4.3