[vorbis-dev] PATCH: Falling off the end of linked lists.
volsung at asu.edu
volsung at asu.edu
Mon Jun 19 07:58:43 PDT 2000
[I'm still poking around in vorbis-tools. Here's another trivial patch.]
In ogg123.c, the function get_stream goes down a linked list looking for the
nth stream. Currently it will run off the end of the list and dereference the
NULL pointer if the list is smaller than n. Attached is a patch to check for
a null list and abort.
Would assert() be a better way to do this?
-=-=-
Stan Seibert
Index: vorbis-tools/ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vorbis-tools/ogg123.c,v
retrieving revision 1.1
diff -u -r1.1 ogg123.c
--- vorbis-tools/ogg123.c 2000/06/14 23:07:47 1.1
+++ vorbis-tools/ogg123.c 2000/06/19 14:44:16
@@ -104,20 +104,28 @@
FILE *
get_stream (int num, struct streams * streams_list)
{
- if (num < 0)
+ if (streams_list != NULL)
{
- fprintf (stderr, "Internal error: get_stream called with a negative argument.\n");
- exit (1);
+ if (num < 0)
+ {
+ fprintf (stderr, "Internal error: get_stream called with a negative argument.\n");
+ exit (1);
+ }
+ else
+ if (num == 0)
+ {
+ return streams_list->stream;
+ }
+ else
+ {
+ return get_stream ( num--, streams_list->next_stream );
+ }
}
else
- if (num == 0)
- {
- return streams_list->stream;
- }
- else
- {
- return get_stream ( num--, streams_list->next_stream );
- }
+ {
+ fprintf (stderr, "Internal error: get_stream called with NULL stream_list.\n");
+ exit (1);
+ }
}
void usage ()
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
More information about the Vorbis-dev
mailing list