summaryrefslogtreecommitdiffstats
path: root/src/blueshift_randr.pyx
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-04 15:23:18 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-04 15:23:31 +0200
commit858e273164bd1e4675c591b0f561c0855949d5dd (patch)
tree1855ba200183d38821798036f575068b35006ca0 /src/blueshift_randr.pyx
parentmulti-display support can apply once, then it segfaults (diff)
downloadblueshift-858e273164bd1e4675c591b0f561c0855949d5dd.tar.gz
blueshift-858e273164bd1e4675c591b0f561c0855949d5dd.tar.bz2
blueshift-858e273164bd1e4675c591b0f561c0855949d5dd.tar.xz
fix double free error and sigfault error in multi-display support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/blueshift_randr.pyx')
-rw-r--r--src/blueshift_randr.pyx11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/blueshift_randr.pyx b/src/blueshift_randr.pyx
index e845f65..80caab1 100644
--- a/src/blueshift_randr.pyx
+++ b/src/blueshift_randr.pyx
@@ -32,11 +32,6 @@ cdef extern void blueshift_randr_close()
cdef unsigned short int* r_c
cdef unsigned short int* g_c
cdef unsigned short int* b_c
-r_c = <unsigned short int*>malloc(256 * 2)
-g_c = <unsigned short int*>malloc(256 * 2)
-b_c = <unsigned short int*>malloc(256 * 2)
-if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
- raise MemoryError()
@@ -48,9 +43,15 @@ def randr_open(int use_screen, display):
@param display:bytes? The display to use, `None` for the current
@return :int Zero on success
'''
+ global r_c, g_c, b_c
cdef char* display_ = NULL
if display is not None:
display_ = display
+ r_c = <unsigned short int*>malloc(256 * 2)
+ g_c = <unsigned short int*>malloc(256 * 2)
+ b_c = <unsigned short int*>malloc(256 * 2)
+ if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
+ raise MemoryError()
return blueshift_randr_open(use_screen, display_)