diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h index ddfe260b..68ec1573 100644 --- a/libxrdp/libxrdp.h +++ b/libxrdp/libxrdp.h @@ -265,6 +265,9 @@ struct xrdp_orders struct xrdp_orders_state orders_state; void *jpeg_han; int rfx_min_pixel; + /* shared */ + struct stream *s; + struct stream *temp_s; }; #define PROTO_RDP_40 1 diff --git a/libxrdp/xrdp_bitmap32_compress.c b/libxrdp/xrdp_bitmap32_compress.c index d843cff1..a1860ebe 100644 --- a/libxrdp/xrdp_bitmap32_compress.c +++ b/libxrdp/xrdp_bitmap32_compress.c @@ -268,6 +268,8 @@ fout(int collen, int replen, char *colptr, struct stream *s) LLOGLN(10, ("fout: big run lreplen %d", lreplen)); replen -= lreplen; code = ((lreplen & 0xF) << 4) | ((lreplen & 0xF0) >> 4); + out_uint8(s, code); + colptr += lreplen; } else { @@ -282,11 +284,11 @@ fout(int collen, int replen, char *colptr, struct stream *s) lreplen = 0; } code = (collen << 4) | lreplen; + out_uint8(s, code); + out_uint8a(s, colptr, collen); + colptr += collen + lreplen; + collen = 0; } - out_uint8(s, code); - out_uint8a(s, colptr, collen); - colptr += collen + lreplen; - collen = 0; cont = replen > 0; } return 0; diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 88ffda8e..51eac9ca 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -55,6 +55,8 @@ xrdp_orders_create(struct xrdp_session *session, struct xrdp_rdp *rdp_layer) { self->rfx_min_pixel = 64 * 32; } + make_stream(self->s); + make_stream(self->temp_s); return self; } @@ -68,6 +70,8 @@ xrdp_orders_delete(struct xrdp_orders *self) } xrdp_jpeg_deinit(self->jpeg_han); free_stream(self->out_s); + free_stream(self->s); + free_stream(self->temp_s); g_free(self->orders_state.text_data); g_free(self); } @@ -2321,9 +2325,9 @@ xrdp_orders_send_bitmap(struct xrdp_orders *self, e = 4 - e; } - make_stream(s); + s = self->s; init_stream(s, 16384 * 2); - make_stream(temp_s); + temp_s = self->temp_s; init_stream(temp_s, 16384 * 2); p = s->p; i = height; @@ -2341,8 +2345,6 @@ xrdp_orders_send_bitmap(struct xrdp_orders *self, if (lines_sending != height) { - free_stream(s); - free_stream(temp_s); g_writeln("error in xrdp_orders_send_bitmap, lines_sending(%d) != \ height(%d)", lines_sending, height); return 1; @@ -2390,8 +2392,6 @@ height(%d)", lines_sending, height); } out_uint8a(self->out_s, s->data, bufsize); - free_stream(s); - free_stream(temp_s); return 0; } @@ -2590,9 +2590,9 @@ xrdp_orders_send_bitmap2(struct xrdp_orders *self, e = 4 - e; } - make_stream(s); + s = self->s; init_stream(s, 16384 * 2); - make_stream(temp_s); + temp_s = self->temp_s; init_stream(temp_s, 16384 * 2); p = s->p; i = height; @@ -2610,8 +2610,6 @@ xrdp_orders_send_bitmap2(struct xrdp_orders *self, if (lines_sending != height) { - free_stream(s); - free_stream(temp_s); g_writeln("error in xrdp_orders_send_bitmap2, lines_sending(%d) != \ height(%d)", lines_sending, height); return 1; @@ -2640,8 +2638,6 @@ height(%d)", lines_sending, height); i = cache_idx & 0xff; out_uint8(self->out_s, i); out_uint8a(self->out_s, s->data, bufsize); - free_stream(s); - free_stream(temp_s); return 0; }