summaryrefslogtreecommitdiffstats
path: root/x11vnc/scan.c
diff options
context:
space:
mode:
authorrunge <runge>2008-01-15 04:27:11 +0000
committerrunge <runge>2008-01-15 04:27:11 +0000
commitc07091b3900ad1d66bb9665a892bf93c685d031a (patch)
tree13be8939702009f53bffec7d85ff61a5fe13789a /x11vnc/scan.c
parent649f5b2b4615ae67d97eff7f3fa246a1ac41edf9 (diff)
downloadlibtdevnc-c07091b3900ad1d66bb9665a892bf93c685d031a.tar.gz
libtdevnc-c07091b3900ad1d66bb9665a892bf93c685d031a.zip
x11vnc: -ping option, fix memory corruption in copy_tiles after xrandr resize.
Diffstat (limited to 'x11vnc/scan.c')
-rw-r--r--x11vnc/scan.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/x11vnc/scan.c b/x11vnc/scan.c
index 5dbefe9..23fd32d 100644
--- a/x11vnc/scan.c
+++ b/x11vnc/scan.c
@@ -1659,8 +1659,8 @@ static void mark_hint(hint_t hint) {
* devices are optimized for write, not read, so we are limited by the
* read bandwidth, sometimes only 5 MB/sec on otherwise fast hardware.
*/
-static int *first_line = NULL, *last_line;
-static unsigned short *left_diff, *right_diff;
+static int *first_line = NULL, *last_line = NULL;
+static unsigned short *left_diff = NULL, *right_diff = NULL;
static int copy_tiles(int tx, int ty, int nt) {
int x, y, line;
@@ -1670,14 +1670,23 @@ static int copy_tiles(int tx, int ty, int nt) {
int pixelsize = bpp/8;
int first_min, last_max;
int first_x = -1, last_x = -1;
+ static int prev_ntiles_x = -1;
char *src, *dst, *s_src, *s_dst, *m_src, *m_dst;
char *h_src, *h_dst;
if (unixpw_in_progress) return 0;
- if (! first_line) {
+ if (ntiles_x != prev_ntiles_x && first_line != NULL) {
+ free(first_line); first_line = NULL;
+ free(last_line); last_line = NULL;
+ free(left_diff); left_diff = NULL;
+ free(right_diff); right_diff = NULL;
+ }
+
+ if (first_line == NULL) {
/* allocate arrays first time in. */
int n = ntiles_x + 1;
+ rfbLog("copy_tiles: allocating first_line at size %d\n", n);
first_line = (int *) malloc((size_t) (n * sizeof(int)));
last_line = (int *) malloc((size_t) (n * sizeof(int)));
left_diff = (unsigned short *)
@@ -1685,6 +1694,7 @@ static int copy_tiles(int tx, int ty, int nt) {
right_diff = (unsigned short *)
malloc((size_t) (n * sizeof(unsigned short)));
}
+ prev_ntiles_x = ntiles_x;
x = tx * tile_x;
y = ty * tile_y;
@@ -3354,6 +3364,11 @@ if (tile_count) fprintf(stderr, "XX copytile: %.4f tile_count: %d\n", dnow() -
} else if (use_openssl && !tile_diffs) {
ping_clients(0);
}
+ /* -ping option: */
+ if (ping_interval) {
+ int td = ping_interval > 0 ? ping_interval : -ping_interval;
+ ping_clients(-td);
+ }
nap_check(tile_diffs);