https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0e83dd032c7c76e368c3a…
commit 0e83dd032c7c76e368c3aeb45771d9a048e864b0
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Mar 13 00:16:30 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:09 2022 +0100
[WINESYNC] msi: Factor out int_to_table_storage().
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 99425f272f7807aea068629ef3e5fda6640b2845 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/table.c | 53 +++++++++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/dll/win32/msi/table.c b/dll/win32/msi/table.c
index b507268eb7c..e4f6b56f18a 100644
--- a/dll/win32/msi/table.c
+++ b/dll/win32/msi/table.c
@@ -1201,6 +1201,26 @@ static UINT TABLE_set_int( MSITABLEVIEW *tv, UINT row, UINT col,
UINT val )
return ERROR_SUCCESS;
}
+static UINT int_to_table_storage( const MSITABLEVIEW *tv, UINT col, int val, UINT *ret )
+{
+ if ((tv->columns[col-1].type & MSI_DATASIZEMASK) == 2)
+ {
+ if (val == MSI_NULL_INTEGER)
+ *ret = 0;
+ else if ((val + 0x8000) & 0xffff0000)
+ {
+ ERR("value %d out of range\n", val);
+ return ERROR_FUNCTION_FAILED;
+ }
+ else
+ *ret = val + 0x8000;
+ }
+ else
+ *ret = val ^ 0x80000000;
+
+ return ERROR_SUCCESS;
+}
+
static UINT TABLE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec )
{
MSITABLEVIEW *tv = (MSITABLEVIEW *)view;
@@ -1276,7 +1296,6 @@ static UINT get_table_value_from_record( MSITABLEVIEW *tv, MSIRECORD
*rec, UINT
{
MSICOLUMNINFO columninfo;
UINT r;
- int ival;
if (!iField || iField > tv->num_cols || MSI_RecordIsNull( rec, iField ))
return ERROR_FUNCTION_FAILED;
@@ -1299,25 +1318,8 @@ static UINT get_table_value_from_record( MSITABLEVIEW *tv,
MSIRECORD *rec, UINT
}
else *pvalue = 0;
}
- else if ( bytes_per_column( tv->db, &columninfo, LONG_STR_BYTES ) == 2 )
- {
- ival = MSI_RecordGetInteger( rec, iField );
- if (ival == 0x80000000) *pvalue = 0x8000;
- else
- {
- *pvalue = 0x8000 + MSI_RecordGetInteger( rec, iField );
- if (*pvalue & 0xffff0000)
- {
- ERR("field %u value %d out of range\n", iField, *pvalue -
0x8000);
- return ERROR_FUNCTION_FAILED;
- }
- }
- }
else
- {
- ival = MSI_RecordGetInteger( rec, iField );
- *pvalue = ival ^ 0x80000000;
- }
+ return int_to_table_storage( tv, iField, MSI_RecordGetInteger( rec, iField ),
pvalue );
return ERROR_SUCCESS;
}
@@ -2370,14 +2372,11 @@ static UINT* msi_record_to_row( const MSITABLEVIEW *tv, MSIRECORD
*rec )
}
else
{
- data[i] = MSI_RecordGetInteger( rec, i+1 );
-
- if (data[i] == MSI_NULL_INTEGER)
- data[i] = 0;
- else if ((tv->columns[i].type&0xff) == 2)
- data[i] += 0x8000;
- else
- data[i] += 0x80000000;
+ if (int_to_table_storage( tv, i + 1, MSI_RecordGetInteger( rec, i + 1 ),
&data[i] ))
+ {
+ msi_free( data );
+ return NULL;
+ }
}
}
return data;