[Bug 2139] New: Edit control bug in EDIT_EM_GetLine (multiple lines) for lines with zero length

Wine Bugs wine-bugs at winehq.org
Thu Apr 1 02:36:33 CST 2004


http://bugs.winehq.org/show_bug.cgi?id=2139

           Summary: Edit control bug in EDIT_EM_GetLine (multiple lines) for
                    lines with zero length
           Product: Wine
           Version: 20040309
          Platform: PC
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: major
          Priority: P2
         Component: wine-winelib
        AssignedTo: wine-bugs at winehq.org
        ReportedBy: r.kessel at metrodata.de


The EM_GETLINE message handler has a bug in handling multiple line controls when
they contain lines with zero length.

Problem:
Instead of returning an empty line, EDIT_EM_GetLine does nothing and returns the
buffer length as the character count.

Most likely the problem is in the following section:

	{
	    LPSTR dst = (LPSTR)lParam;
	    INT ret;
	    ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, dst, dst_len, NULL, NULL);
	    if(!ret) /* Insufficient buffer size */
		return dst_len;
	    if(ret < dst_len) /* Append 0 if enough space */
		dst[ret] = 0;
	    return ret;
	}

In case that line_len is zero WideCharToMultiByte returns correctly zero, but
this is treated as an insufficient buffer size.

Possible solution:

	{
	    LPSTR dst = (LPSTR)lParam;
	    INT ret;
            if(line_len)
            {
	      ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, dst, dst_len, NULL,
NULL);
	    if(!ret) /* Insufficient buffer size */
		return dst_len;
            }
            else
            {
            ret = 0;
            }
	    if(ret < dst_len) /* Append 0 if enough space */
		dst[ret] = 0;
	    return ret;
	}

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the wine-bugs mailing list