[xiph-commits] r3787 - liboggz/trunk/src/liboggz
giles at svn.annodex.net
giles at svn.annodex.net
Mon Nov 17 10:59:46 PST 2008
Author: giles
Date: 2008-11-17 10:59:45 -0800 (Mon, 17 Nov 2008)
New Revision: 3787
Modified:
liboggz/trunk/src/liboggz/oggz_seek.c
liboggz/trunk/src/liboggz/oggz_write.c
Log:
Move dereferences after null argument checks.
Problem reported by the Coverity static analysis tool.
Modified: liboggz/trunk/src/liboggz/oggz_seek.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_seek.c 2008-11-15 23:34:18 UTC (rev 3786)
+++ liboggz/trunk/src/liboggz/oggz_seek.c 2008-11-17 18:59:45 UTC (rev 3787)
@@ -614,7 +614,7 @@
static ogg_int64_t
oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
{
- OggzReader * reader = &oggz->x.reader;
+ OggzReader * reader;
oggz_off_t offset_orig, offset_at, offset_guess;
oggz_off_t offset_begin, offset_end = -1, offset_next;
ogg_int64_t granule_at;
@@ -641,6 +641,8 @@
return -1;
}
+ reader = &oggz->x.reader;
+
if (unit_target == reader->current_unit) {
#ifdef DEBUG
printf ("oggz_seek_set: unit_target == reader->current_unit, SKIP\n");
@@ -823,7 +825,7 @@
off_t
oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence)
{
- OggzReader * reader = &oggz->x.reader;
+ OggzReader * reader;
ogg_int64_t units = -1;
if (oggz == NULL) return -1;
@@ -833,7 +835,9 @@
}
if (offset == 0 && whence == SEEK_SET) units = 0;
-
+
+ reader = &oggz->x.reader;
+
if (!(offset == 0 && whence == SEEK_CUR)) {
/* Invalidate current_unit */
reader->current_unit = -1;
@@ -845,7 +849,7 @@
ogg_int64_t
oggz_seek_units (OGGZ * oggz, ogg_int64_t units, int whence)
{
- OggzReader * reader = &oggz->x.reader;
+ OggzReader * reader;
ogg_int64_t r;
@@ -870,6 +874,8 @@
return -1;
}
+ reader = &oggz->x.reader;
+
switch (whence) {
case SEEK_SET:
r = oggz_seek_set (oggz, units);
Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c 2008-11-15 23:34:18 UTC (rev 3786)
+++ liboggz/trunk/src/liboggz/oggz_write.c 2008-11-17 18:59:45 UTC (rev 3787)
@@ -373,13 +373,14 @@
static long
oggz_page_init (OGGZ * oggz)
{
- OggzWriter * writer = &oggz->x.writer;
+ OggzWriter * writer;
ogg_stream_state * os;
ogg_page * og;
int ret;
if (oggz == NULL) return -1;
+ writer = &oggz->x.writer;
os = writer->current_stream;
og = &oggz->current_page;
@@ -414,13 +415,14 @@
static long
oggz_packet_init (OGGZ * oggz, oggz_writer_packet_t * next_zpacket)
{
- OggzWriter * writer = &oggz->x.writer;
+ OggzWriter * writer;
oggz_stream_t * stream;
ogg_stream_state * os;
ogg_packet * op;
if (oggz == NULL) return -1L;
+ writer = &oggz->x.writer;
writer->current_zpacket = next_zpacket;
op = &next_zpacket->op;
@@ -449,12 +451,13 @@
static long
oggz_page_copyout (OGGZ * oggz, unsigned char * buf, long n)
{
- OggzWriter * writer = &oggz->x.writer;
+ OggzWriter * writer;
long h, b;
ogg_page * og;
if (oggz == NULL) return -1L;
+ writer = &oggz->x.writer;
og = &oggz->current_page;
h = MIN (n, og->header_len - writer->page_offset);
@@ -491,7 +494,7 @@
static long
oggz_page_writeout (OGGZ * oggz, long n)
{
- OggzWriter * writer = &oggz->x.writer;
+ OggzWriter * writer;
long h, b, nwritten;
ogg_page * og;
@@ -501,6 +504,7 @@
if (oggz == NULL) return -1L;
+ writer = &oggz->x.writer;
og = &oggz->current_page;
#ifdef OGGZ_WRITE_DIRECT
@@ -901,11 +905,13 @@
long
oggz_write_get_next_page_size (OGGZ * oggz)
{
- OggzWriter * writer = &oggz->x.writer;
+ OggzWriter * writer;
ogg_page * og;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
+ writer = &oggz->x.writer;
+
if (!(oggz->flags & OGGZ_WRITE)) {
return OGGZ_ERR_INVALID;
}
More information about the commits
mailing list