Skip to content

Commit

Permalink
Return an error from parse if ancestor stack is NULL. Fix for Mozilla…
Browse files Browse the repository at this point in the history
… bz#604993.
  • Loading branch information
kinetiknz committed Oct 18, 2010
1 parent a083fa0 commit 7145428
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/nestegg.c
Expand Up @@ -967,6 +967,10 @@ ne_parse(nestegg * ctx, struct ebml_element_desc * top_level)
push ctx onto stack and continue if sublevel ended, pop ctx off stack
and continue */

if (!ctx->ancestor) {
return -1;
}

for (;;) {
r = ne_peek_element(ctx, &id, &size);
if (r != 1)
Expand Down Expand Up @@ -1028,8 +1032,9 @@ ne_parse(nestegg * ctx, struct ebml_element_desc * top_level)
}

if (r != 1) {
while(ctx->ancestor)
while (ctx->ancestor) {
ne_ctx_pop(ctx);
}
}

return r;
Expand Down
3 changes: 3 additions & 0 deletions test/test.c
Expand Up @@ -12,6 +12,7 @@
#include "nestegg/nestegg.h"

#undef DEBUG
#undef SEEK_TEST

static int
stdio_read(void * p, size_t length, void * fp)
Expand Down Expand Up @@ -145,6 +146,7 @@ main(int argc, char * argv[])
#endif
}

#ifdef SEEK_TEST
#ifdef DEBUG
fprintf(stderr, "seek to middle\n");
#endif
Expand Down Expand Up @@ -216,6 +218,7 @@ main(int argc, char * argv[])
#endif
}
}
#endif

while (nestegg_read_packet(ctx, &pkt) > 0) {
nestegg_packet_track(pkt, &pkt_track);
Expand Down

0 comments on commit 7145428

Please sign in to comment.