summaryrefslogtreecommitdiff
blob: 876ed9eb6de0e0fccbf7f76a5a1e61adc2f7bb5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fix that is already in upstream x11vnc-0.9.14 dev

from ChromiumOS:

x11vnc: Fix shm close on early shutdown.

Global structures {scanline,fullscreen,scanrect}_shm are initialized to
zero, including the .shmid field. This creates problems when shutdown /
clean_shm is called before these structures are properly initialized in
initialize_polling_images. shm_delete will be called on the structure,
and since the shmid isn't -1, shmctl(id, IPC_RMID...) will be called for
id=0. id=0 is in fact a valid shmid, and it might belong to some other
shared memory for some other processes, creating many potential problems.

Fix is to initialize shmid to -1 to indicate that it is in fact
uninitialized.

https://gerrit.chromium.org/gerrit/37971

--- a/x11vnc/x11vnc_defs.c
+++ b/x11vnc/x11vnc_defs.c
@@ -82,10 +82,10 @@
 XImage *raw_fb_image = NULL;	/* the raw fb */

 /* corresponding shm structures */
-XShmSegmentInfo scanline_shm;
-XShmSegmentInfo fullscreen_shm;
+XShmSegmentInfo scanline_shm = {.shmid = -1};
+XShmSegmentInfo fullscreen_shm = {.shmid = -1};
 XShmSegmentInfo *tile_row_shm;	/* for all possible row runs */
-XShmSegmentInfo snaprect_shm;
+XShmSegmentInfo snaprect_shm = {.shmid = -1};

 /* rfb screen info */
 rfbScreenInfoPtr screen = NULL;