From 858e273164bd1e4675c591b0f561c0855949d5dd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 4 Apr 2014 15:23:18 +0200 Subject: fix double free error and sigfault error in multi-display support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blueshift_vidmode.pyx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/blueshift_vidmode.pyx') diff --git a/src/blueshift_vidmode.pyx b/src/blueshift_vidmode.pyx index 7ad7a4c..c591db5 100644 --- a/src/blueshift_vidmode.pyx +++ b/src/blueshift_vidmode.pyx @@ -38,11 +38,6 @@ vidmode_gamma_size = 0 cdef unsigned short int* r_c cdef unsigned short int* g_c cdef unsigned short int* b_c -r_c = malloc(256 * 2) -g_c = malloc(256 * 2) -b_c = malloc(256 * 2) -if (r_c is NULL) or (g_c is NULL) or (b_c is NULL): - raise MemoryError() @@ -54,10 +49,15 @@ def vidmode_open(int use_screen, display): @param display:bytes? The display to use, `None` for the current @return :bool Whether call was successful ''' - global vidmode_gamma_size + global vidmode_gamma_size, r_c, g_c, b_c cdef char* display_ = NULL if display is not None: display_ = display + r_c = malloc(256 * 2) + g_c = malloc(256 * 2) + b_c = malloc(256 * 2) + if (r_c is NULL) or (g_c is NULL) or (b_c is NULL): + raise MemoryError() vidmode_gamma_size = blueshift_vidmode_open(use_screen, display_) return vidmode_gamma_size > 1 -- cgit v1.2.3-70-g09d2