1. Changed fixed-size buffer to dynamic allocation for link_name to prevent buffer overflow 2. Added proper memory cleanup with HeapFree in all error paths 3. Fixed potential null pointer dereference when device is NULL 4. Improved error handling by checking memory allocation success
The original code used a fixed-size buffer (15 chars) which could overflow with long device names. The new version dynamically allocates memory based on actual device name length, includes proper cleanup, and handles edge cases better.
Signed-off-by: Wei Xie xiewei@uniontech.com
-- v2: fix: add missing DefineDosDeviceW test cases kernelbase: fix memory allocation in DefineDosDeviceW