Ticket #4837: libs_libmythtv_osdchromakey.cpp-move-up-null-check.patch

File libs_libmythtv_osdchromakey.cpp-move-up-null-check.patch, 2.0 KB (added by Erik Hovland <erik@…>, 16 years ago)

moves the null pointer check up before the first dereference

  • libs/libmythtv/osdchromakey.cpp

    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythtv/osdchromakey.cpp |   36 ++++++++++++++++++------------------
     1 files changed, 18 insertions(+), 18 deletions(-)
    
    diff --git a/libs/libmythtv/osdchromakey.cpp b/libs/libmythtv/osdchromakey.cpp
    index 07bc2e2..ed7e8f2 100644
    a b void ChromaKeyOSD::AllocImage(int i) 
    3232                        &shm_infos[i],
    3333                        videoOutput->display_visible_rect.width(),
    3434                        videoOutput->display_visible_rect.height());
     35    if (!shm_img)
     36        return;
     37
    3538    uint size = shm_img->bytes_per_line * (shm_img->height+1) + 128;
    3639    X11U;
    3740
    38     if (shm_img)
     41    shm_infos[i].shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
     42    if (shm_infos[i].shmid >= 0)
    3943    {
    40         shm_infos[i].shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
    41         if (shm_infos[i].shmid >= 0)
    42         {
    43             shm_infos[i].shmaddr = (char*) shmat(shm_infos[i].shmid, 0, 0);
    44 
    45             shm_img->data = shm_infos[i].shmaddr;
    46             shm_infos[i].readOnly = False;
    47 
    48             X11L;
    49             XShmAttach(videoOutput->XJ_disp, &shm_infos[i]);
    50             XSync(videoOutput->XJ_disp, False); // needed for FreeBSD?
    51             X11U;
    52 
    53             // Mark for delete immediately.
    54             // It won't actually be removed until after we detach it.
    55             shmctl(shm_infos[i].shmid, IPC_RMID, 0);
    56         }
     44        shm_infos[i].shmaddr = (char*) shmat(shm_infos[i].shmid, 0, 0);
     45
     46        shm_img->data = shm_infos[i].shmaddr;
     47        shm_infos[i].readOnly = False;
     48
     49        X11L;
     50        XShmAttach(videoOutput->XJ_disp, &shm_infos[i]);
     51        XSync(videoOutput->XJ_disp, False); // needed for FreeBSD?
     52        X11U;
     53
     54        // Mark for delete immediately.
     55        // It won't actually be removed until after we detach it.
     56        shmctl(shm_infos[i].shmid, IPC_RMID, 0);
    5757    }
    5858
    5959    img[i] = shm_img;