Ignore:
Timestamp:
Dec 16, 2018, 7:15:42 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
e406835
Parents:
0f5d372
Message:

[io] prevent crash on empty string and potential leak in sink_apple_audio

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_apple_audio.c

    r0f5d372 rcf387e3  
    6262  s->async = false;
    6363
    64   if ( (uri == NULL) || (strlen(uri) < 1) ) {
     64  if ( (uri == NULL) || (strnlen(uri, PATH_MAX) < 1) ) {
    6565    AUBIO_ERROR("sink_apple_audio: Aborted opening null path\n");
    6666    goto beach;
    6767  }
    68   if (s->path != NULL) AUBIO_FREE(s->path);
     68
    6969  s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX) + 1);
    7070  strncpy(s->path, uri, strnlen(uri, PATH_MAX) + 1);
     
    9292  return s;
    9393beach:
    94   AUBIO_FREE(s);
     94  del_aubio_sink_apple_audio(s);
    9595  return NULL;
    9696}
     
    103103  s->samplerate = samplerate;
    104104  // automatically open when both samplerate and channels have been set
    105   if (s->samplerate != 0 && s->channels != 0) {
     105  if (/* s->samplerate != 0 && */ s->channels != 0) {
    106106    return aubio_sink_apple_audio_open(s);
    107107  }
     
    116116  s->channels = channels;
    117117  // automatically open when both samplerate and channels have been set
    118   if (s->samplerate != 0 && s->channels != 0) {
     118  if (s->samplerate != 0 /* && s->channels != 0 */) {
    119119    return aubio_sink_apple_audio_open(s);
    120120  }
     
    250250
    251251void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) {
    252   if (s->audioFile) aubio_sink_apple_audio_close (s);
    253   if (s->path) AUBIO_FREE(s->path);
     252  AUBIO_ASSERT(s);
     253  if (s->audioFile)
     254    aubio_sink_apple_audio_close (s);
     255  if (s->path)
     256    AUBIO_FREE(s->path);
    254257  freeAudioBufferList(&s->bufferList);
    255258  AUBIO_FREE(s);
    256   return;
    257259}
    258260
Note: See TracChangeset for help on using the changeset viewer.