zero allocated class memory

This commit is contained in:
Josh Coalson
2002-08-03 22:05:11 +00:00
parent 189267013e
commit a7e4fb2629
4 changed files with 17 additions and 2 deletions

View File

@@ -146,17 +146,23 @@ FLAC__StreamDecoder *FLAC__stream_decoder_new()
if(decoder == 0) {
return 0;
}
memset(decoder, 0, sizeof(FLAC__StreamDecoder));
decoder->protected_ = (FLAC__StreamDecoderProtected*)malloc(sizeof(FLAC__StreamDecoderProtected));
if(decoder->protected_ == 0) {
free(decoder);
return 0;
}
memset(decoder->protected_, 0, sizeof(FLAC__StreamDecoderProtected));
decoder->private_ = (FLAC__StreamDecoderPrivate*)malloc(sizeof(FLAC__StreamDecoderPrivate));
if(decoder->private_ == 0) {
free(decoder->protected_);
free(decoder);
return 0;
}
memset(decoder->private_, 0, sizeof(FLAC__StreamDecoderPrivate));
decoder->private_->input = FLAC__bitbuffer_new();
if(decoder->private_->input == 0) {
free(decoder->private_);