From 20431deb4e739c87b03f21635027b16f0f587202 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Feb 2015 07:47:18 -0500 Subject: [PATCH] Guard against potential null pointer dereferences --- libctru/source/services/csnd.c | 2 +- libctru/source/services/soc/soc_ioctl.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libctru/source/services/csnd.c b/libctru/source/services/csnd.c index 3c8012d..994443f 100644 --- a/libctru/source/services/csnd.c +++ b/libctru/source/services/csnd.c @@ -410,7 +410,7 @@ Result csndPlaySound(int chn, u32 flags, u32 sampleRate, void* data0, void* data if (data0) paddr0 = osConvertVirtToPhys((u32)data0); if (data1) paddr1 = osConvertVirtToPhys((u32)data1); - if (encoding == CSND_ENCODING_ADPCM) + if (data0 && encoding == CSND_ENCODING_ADPCM) { int adpcmSample = ((s16*)data0)[-2]; int adpcmIndex = ((u8*)data0)[-2]; diff --git a/libctru/source/services/soc/soc_ioctl.c b/libctru/source/services/soc/soc_ioctl.c index 4125646..ec4e691 100644 --- a/libctru/source/services/soc/soc_ioctl.c +++ b/libctru/source/services/soc/soc_ioctl.c @@ -18,7 +18,8 @@ int ioctl(int fd, int request, ...) value = va_arg(ap, int*); if(value == NULL) { errno = EFAULT; - ret = -1; + va_end(ap); + return -1; } flags = fcntl(fd, F_GETFL, 0);