Ticket #4747: libs_libmyth_bio2jack.c-return-if-malloc-fails.patch

File libs_libmyth_bio2jack.c-return-if-malloc-fails.patch, 742 bytes (added by Erik Hovland <erik@…>, 16 years ago)

Adds a return to a null pointer check so the potentially null pointer is not dereferenced

  • libs/libmyth/bio2jack.c

    When null is checked after dynamic allocation we need to return. If we
    
    From: Erik Hovland <erik@hovland.org>
    
    don't then we will attempt to dereference a null pointer and segfault.
    ---
    
     libs/libmyth/bio2jack.c |    1 +
     1 files changed, 1 insertions(+), 0 deletions(-)
    
    diff --git a/libs/libmyth/bio2jack.c b/libs/libmyth/bio2jack.c
    index b4b348d..5589350 100755
    a b long JACK_Write(int deviceID, unsigned char *data, unsigned long bytes) 
    12181218  if (!newWaveHeader)
    12191219  {
    12201220    ERR("error allocating memory for newWaveHeader\n");
     1221    return 0;
    12211222  }
    12221223
    12231224  newWaveHeader->pData = (unsigned char*)malloc(sizeof(unsigned char) * bytes); /* allocate memory for the data */