https://bugs.winehq.org/show_bug.cgi?id=56560
Bug ID: 56560 Summary: There is a memory leak defect at line 1068 in the file /wine/dlls/winex11.drv/clipboard.c. Product: Wine Version: 9.6 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: major Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: lumingying@bupt.edu.cn Distribution: ---
Trigger Path for the Defect:
1.A pointer variable named "path" is defined at line 1056 in the file /wine/dlls/winex11.drv/clipboard.c. This pointer allocates a dynamic memory area through the function "get_dos_file_name" at line 1060, as shown in the following diagram: https://github.com/LuMingYinDetect/wine_defects/blob/main/wine_1.png
2.The function "get_dos_file_name" allocates a dynamic memory area and returns it. Specifically, at line 587, a pointer variable named "ret" is defined. At line 589, memory space is allocated for the "ret" variable using the function "malloc," and at line 602, this variable is returned, as shown in the following diagram: https://github.com/LuMingYinDetect/wine_defects/blob/main/wine_2.png
3.After the execution of the "get_dos_file_name" function, when the conditional statement at line 1064 returns false, it indicates that the dynamic memory area pointed to by the "path" variable is successfully allocated. However, when the conditional statement at line 1068 returns true, the program exits without releasing the memory. In this process, the dynamic memory area pointed to by the "path" pointer is not freed, resulting in a memory leak defect, as shown in the following diagram: https://github.com/LuMingYinDetect/wine_defects/blob/main/wine_3.png