fix some cases that didn't return outofmem error properly and would crash instead

This commit is contained in:
Sean Barrett
2015-09-03 07:11:02 -07:00
parent a009673856
commit 0e24ec5feb
2 changed files with 49 additions and 12 deletions

View File

@ -57,12 +57,30 @@ int main(int argc, char **argv)
int num_chan, samprate;
int i, j, test, phase;
short *output;
if (argc == 1) {
fprintf(stderr, "Usage: vorbseek {vorbisfile} [{vorbisfile]*]\n");
fprintf(stderr, "Tests various seek offsets to make sure they're sample exact.\n");
return 0;
}
#if 0
{
// check that outofmem occurs correctly
stb_vorbis_alloc va;
va.alloc_buffer = malloc(1024*1024);
for (i=0; i < 1024*1024; i += 10) {
int error=0;
stb_vorbis *v;
va.alloc_buffer_length_in_bytes = i;
v = stb_vorbis_open_filename(argv[1], &error, &va);
if (v != NULL)
break;
printf("Error %d at %d\n", error, i);
}
}
#endif
for (j=1; j < argc; ++j) {
unsigned int successes=0, attempts = 0;
unsigned int num_samples = stb_vorbis_decode_filename(argv[j], &num_chan, &samprate, &output);