]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix NULL dereference in jam and avw video playback when out of memory
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 1 Apr 2012 13:30:16 +0000 (13:30 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 1 Apr 2012 13:30:16 +0000 (13:30 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11778 d7cf8633-e32d-0410-b094-e92efae38249

cl_video_jamdecode.c
cl_video_libavw.c

index 475f1f7b2d9400b2745954290060e8e503697792..04bd63489dfe7253df7ebc91b387e1474809aee8 100644 (file)
@@ -53,12 +53,12 @@ void *jam_open(clvideo_t *video, char *filename, const char **errorstring)
        // allocate stream structure
        s = (jamdecodestream_t *)Z_Malloc(sizeof(jamdecodestream_t));
        memset(s, 0, sizeof(jamdecodestream_t));
-       s->sndchan = -1;
        if (s == NULL)
        {
                *errorstring = "unable to allocate memory for stream info structure";
                return NULL;
        }
+       s->sndchan = -1;
 
        // open file
        s->file = FS_OpenVirtualFile(filename, true);
@@ -375,4 +375,4 @@ readframe:
 #endif
        }
        return 0;
-}
\ No newline at end of file
+}
index 206b9c6998ad9c8a4de8faa7940db9f5f74765ee..7924127a1def8d555c00a471188a458e0545f608 100644 (file)
@@ -260,13 +260,13 @@ static void *LibAvW_OpenVideo(clvideo_t *video, char *filename, const char **err
 
        // allocate stream
        s = (libavwstream_t *)Z_Malloc(sizeof(libavwstream_t));
-       s->sndchan = -1;
-       memset(s, 0, sizeof(libavwstream_t));
        if (s == NULL)
        {
                *errorstring = "unable to allocate memory for stream info structure";
                return NULL;
        }
+       memset(s, 0, sizeof(libavwstream_t));
+       s->sndchan = -1;
 
        // open file
        s->file = FS_OpenVirtualFile(filename, true);