forked from Mirrors/wine-wine
server: Store length of window text instead of null-terminating it.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>feature/deterministic
parent
78846662ec
commit
a88973a5f9
|
@ -88,6 +88,7 @@ struct window
|
||||||
DPI_AWARENESS dpi_awareness; /* DPI awareness mode */
|
DPI_AWARENESS dpi_awareness; /* DPI awareness mode */
|
||||||
lparam_t user_data; /* user-specific data */
|
lparam_t user_data; /* user-specific data */
|
||||||
WCHAR *text; /* window caption text */
|
WCHAR *text; /* window caption text */
|
||||||
|
data_size_t text_len; /* length of window caption */
|
||||||
unsigned int paint_flags; /* various painting flags */
|
unsigned int paint_flags; /* various painting flags */
|
||||||
int prop_inuse; /* number of in-use window properties */
|
int prop_inuse; /* number of in-use window properties */
|
||||||
int prop_alloc; /* number of allocated window properties */
|
int prop_alloc; /* number of allocated window properties */
|
||||||
|
@ -506,6 +507,7 @@ static struct window *create_window( struct window *parent, struct window *owner
|
||||||
win->dpi = 0;
|
win->dpi = 0;
|
||||||
win->user_data = 0;
|
win->user_data = 0;
|
||||||
win->text = NULL;
|
win->text = NULL;
|
||||||
|
win->text_len = 0;
|
||||||
win->paint_flags = 0;
|
win->paint_flags = 0;
|
||||||
win->prop_inuse = 0;
|
win->prop_inuse = 0;
|
||||||
win->prop_alloc = 0;
|
win->prop_alloc = 0;
|
||||||
|
@ -2407,10 +2409,10 @@ DECL_HANDLER(get_window_text)
|
||||||
{
|
{
|
||||||
struct window *win = get_window( req->handle );
|
struct window *win = get_window( req->handle );
|
||||||
|
|
||||||
if (win && win->text)
|
if (win && win->text_len)
|
||||||
{
|
{
|
||||||
reply->length = strlenW( win->text );
|
reply->length = win->text_len / sizeof(WCHAR);
|
||||||
set_reply_data( win->text, min( reply->length * sizeof(WCHAR), get_reply_max_size() ));
|
set_reply_data( win->text, min( win->text_len, get_reply_max_size() ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2418,21 +2420,16 @@ DECL_HANDLER(get_window_text)
|
||||||
/* set the window text */
|
/* set the window text */
|
||||||
DECL_HANDLER(set_window_text)
|
DECL_HANDLER(set_window_text)
|
||||||
{
|
{
|
||||||
|
data_size_t len;
|
||||||
|
WCHAR *text = NULL;
|
||||||
struct window *win = get_window( req->handle );
|
struct window *win = get_window( req->handle );
|
||||||
|
|
||||||
if (win)
|
if (!win) return;
|
||||||
{
|
len = (get_req_data_size() / sizeof(WCHAR)) * sizeof(WCHAR);
|
||||||
WCHAR *text = NULL;
|
if (len && !(text = memdup( get_req_data(), len ))) return;
|
||||||
data_size_t len = get_req_data_size() / sizeof(WCHAR);
|
free( win->text );
|
||||||
if (len)
|
win->text = text;
|
||||||
{
|
win->text_len = len;
|
||||||
if (!(text = mem_alloc( (len+1) * sizeof(WCHAR) ))) return;
|
|
||||||
memcpy( text, get_req_data(), len * sizeof(WCHAR) );
|
|
||||||
text[len] = 0;
|
|
||||||
}
|
|
||||||
free( win->text );
|
|
||||||
win->text = text;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue