Line 0
Link Here
|
|
|
1 |
$OpenBSD: patch-xsel_c,v 1.2 2014/07/07 08:25:16 sthen Exp $ |
2 |
|
3 |
- Format "32" properties use "long", not "int", even on LP64 platforms. |
4 |
- ensure NUM_TARGETS does not exceed MAX_NUM_TARGETS. |
5 |
- plug a memory leak in handle_targets() |
6 |
|
7 |
--- xsel.c.orig 2008-02-12 04:50:18 UTC |
8 |
+++ xsel.c |
9 |
@@ -15,6 +15,7 @@ |
10 |
#include "config.h" |
11 |
#endif |
12 |
|
13 |
+#include <assert.h> |
14 |
#include <stdio.h> |
15 |
#include <stdlib.h> |
16 |
#include <stdarg.h> |
17 |
@@ -465,7 +466,7 @@ get_timestamp (void) |
18 |
*/ |
19 |
|
20 |
/* The jmp_buf to longjmp out of the signal handler */ |
21 |
-static jmp_buf env_alrm; |
22 |
+static sigjmp_buf env_alrm; |
23 |
|
24 |
/* |
25 |
* alarm_handler (sig) |
26 |
@@ -1300,14 +1301,16 @@ handle_targets (Display * display, Windo |
27 |
Atom selection, Time time, MultTrack * mparent) |
28 |
{ |
29 |
Atom * targets_cpy; |
30 |
+ HandleResult r; |
31 |
|
32 |
targets_cpy = malloc (sizeof (supported_targets)); |
33 |
memcpy (targets_cpy, supported_targets, sizeof (supported_targets)); |
34 |
|
35 |
- return |
36 |
- change_property (display, requestor, property, XA_ATOM, 32, |
37 |
+ r = change_property (display, requestor, property, XA_ATOM, 32, |
38 |
PropModeReplace, (unsigned char *)targets_cpy, |
39 |
NUM_TARGETS, selection, time, mparent); |
40 |
+ free(targets_cpy); |
41 |
+ return r; |
42 |
} |
43 |
|
44 |
/* |
45 |
@@ -2078,7 +2081,6 @@ main(int argc, char *argv[]) |
46 |
|
47 |
/* Get the NULL atom */ |
48 |
null_atom = XInternAtom (display, "NULL", False); |
49 |
- NUM_TARGETS++; |
50 |
|
51 |
/* Get the TEXT atom */ |
52 |
text_atom = XInternAtom (display, "TEXT", False); |
53 |
@@ -2097,6 +2099,8 @@ main(int argc, char *argv[]) |
54 |
supported_targets[s++] = XA_STRING; |
55 |
NUM_TARGETS++; |
56 |
|
57 |
+ assert(NUM_TARGETS <= MAX_NUM_TARGETS); |
58 |
+ |
59 |
/* Get the COMPOUND_TEXT atom. |
60 |
* NB. We do not currently serve COMPOUND_TEXT; we can retrieve it but |
61 |
* do not perform charset conversion. |