Previously the Flush method was a no-op that always returned S_OK Now it properly calls FlushFileBuffers on the underlying file handle This ensures that all buffered data is written to disk Added error handling to return STG_E_WRITEFAULT on flush failures This fixes potential data loss issues when using file-based lock bytes
Log: Fixed file flushing to prevent data loss in file operations
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com
From: Jiajin Cui cuijiajin@uniontech.com
Previously the Flush method was a no-op that always returned S_OK Now it properly calls FlushFileBuffers on the underlying file handle This ensures that all buffered data is written to disk Added error handling to return STG_E_WRITEFAULT on flush failures This fixes potential data loss issues when using file-based lock bytes
Log: Fixed file flushing to prevent data loss in file operations
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com --- dlls/ole32/filelockbytes.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/dlls/ole32/filelockbytes.c b/dlls/ole32/filelockbytes.c index d806916f1d5..05de0a77f4b 100644 --- a/dlls/ole32/filelockbytes.c +++ b/dlls/ole32/filelockbytes.c @@ -279,6 +279,19 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt(
static HRESULT WINAPI FileLockBytesImpl_Flush(ILockBytes* iface) { + FileLockBytesImpl *This = impl_from_ILockBytes(iface); + + TRACE("(%p)\n", iface); + + /* verify a sane environment */ + if (!This) return E_FAIL; + + if (This->flProtect != PAGE_READWRITE) + return STG_E_ACCESSDENIED; + + if (!FlushFileBuffers(This->hfile)) + return STG_E_WRITEFAULT; + return S_OK; }
From: Jiajin Cui cuijiajin@uniontech.com
Fixed a memory leak in IPropertyStorage_fnDeleteMultiple when deleting properties by name. Previously, when deleting a property by its name, the code only removed the property from the propid_to_prop dictionary but failed to clean up the bidirectional mapping between property names and IDs in the propid_to_name and name_to_propid dictionaries. This resulted in orphaned dictionary entries and memory leaks.
The fix ensures proper cleanup of both dictionaries when deleting properties by name by: 1. Looking up the property name in the name_to_propid dictionary 2. Removing the property from propid_to_prop dictionary 3. Also removing the bidirectional mappings from propid_to_name and name_to_propid dictionaries
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com --- dlls/ole32/stg_prop.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/dlls/ole32/stg_prop.c b/dlls/ole32/stg_prop.c index 0fe8ecc1840..7cc3d45ea72 100644 --- a/dlls/ole32/stg_prop.c +++ b/dlls/ole32/stg_prop.c @@ -918,7 +918,17 @@ static HRESULT WINAPI IPropertyStorage_fnDeleteMultiple( void *propid;
if (dictionary_find(This->name_to_propid, rgpspec[i].lpwstr, &propid)) + { + void *name; + dictionary_remove(This->propid_to_prop, propid); + + if (dictionary_find(This->propid_to_name, propid, &name)) + { + dictionary_remove(This->propid_to_name, propid); + dictionary_remove(This->name_to_propid, name); + } + } } else {
This merge request was closed by Jiajin Cui.