Skip to content

Commit

Permalink
ALAC : Check return value of of fwrite.
Browse files Browse the repository at this point in the history
In the process change parameter of alac_encode() function from
int32_t to uint32_t.

Thanks to Richard Ash <richard@audacityteam.org> for the report.
  • Loading branch information
erikd committed Aug 16, 2013
1 parent 8a657c2 commit f1bbf2e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ALAC/alac_codec.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2012 Erik de Castro Lopo <erikd@mega-nerd.com>
* Copyright (C) 2012-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
Expand Down Expand Up @@ -92,7 +92,7 @@ int32_t alac_decode (ALAC_DECODER *, struct BitBuffer * bits, int32_t * sampleBu

int32_t alac_encode (ALAC_ENCODER *p, uint32_t numChannels, uint32_t numSamples,
int32_t * theReadBuffer, unsigned char * theWriteBuffer,
int32_t * ioNumBytes) ;
uint32_t * ioNumBytes) ;

void alac_set_fastmode(ALAC_ENCODER * p, int32_t fast) ;

Expand Down
2 changes: 1 addition & 1 deletion src/ALAC/alac_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ EncodeMono(ALAC_ENCODER *p, struct BitBuffer * bitstream, int32_t * inputBuffer,
*/
int32_t
alac_encode(ALAC_ENCODER *p, uint32_t numChannels, uint32_t numSamples,
int32_t * theReadBuffer, unsigned char * theWriteBuffer, int32_t * ioNumBytes)
int32_t * theReadBuffer, unsigned char * theWriteBuffer, uint32_t * ioNumBytes)
{
uint32_t outputSize;
BitBuffer bitstream;
Expand Down
7 changes: 3 additions & 4 deletions src/alac.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@ static int
alac_encode_block (SF_PRIVATE * psf, ALAC_PRIVATE *plac)
{ ALAC_ENCODER *penc = &plac->encoder ;
uint8_t byte_buffer [psf->sf.channels * ALAC_BYTE_BUFFER_SIZE] ;
int32_t num_bytes = 0 ;
uint32_t num_bytes = 0 ;

alac_encode (penc, plac->channels, plac->partial_block_frames, plac->buffer, byte_buffer, &num_bytes) ;

fwrite (byte_buffer, 1, num_bytes, plac->enctmp) ;
if (fwrite (byte_buffer, 1, num_bytes, plac->enctmp) != num_bytes)
return 0 ;
if ((plac->pakt_info = alac_pakt_append (plac->pakt_info, num_bytes)) == NULL)
return 0 ;

Expand All @@ -441,8 +442,6 @@ alac_encode_block (SF_PRIVATE * psf, ALAC_PRIVATE *plac)
return 1 ;
} /* alac_encode_block */



/*============================================================================================
** ALAC read functions.
*/
Expand Down

0 comments on commit f1bbf2e

Please sign in to comment.