From: Paul Brossier Date: Thu, 28 Nov 2013 20:51:15 +0000 (-0500) Subject: src/{fvec,cvec,lvec,fmat}.c: make sure new_ functions return NULL if length <= 0 X-Git-Tag: 0.4.0-beta1~66 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=767990ea552e77c6fb4c80e53455d64cc7adbfa0;p=aubio.git src/{fvec,cvec,lvec,fmat}.c: make sure new_ functions return NULL if length <= 0 --- diff --git a/src/cvec.c b/src/cvec.c index efc89f87..3439810b 100644 --- a/src/cvec.c +++ b/src/cvec.c @@ -22,6 +22,9 @@ #include "cvec.h" cvec_t * new_cvec( uint_t length) { + if ((sint_t)length <= 0) { + return NULL; + } cvec_t * s = AUBIO_NEW(cvec_t); s->length = length/2 + 1; s->norm = AUBIO_ARRAY(smpl_t,s->length); diff --git a/src/fmat.c b/src/fmat.c index 7c0e9280..ec373e11 100644 --- a/src/fmat.c +++ b/src/fmat.c @@ -22,6 +22,9 @@ #include "fmat.h" fmat_t * new_fmat (uint_t length, uint_t height) { + if ((sint_t)length <= 0 || (sint_t)height <= 0 ) { + return NULL; + } fmat_t * s = AUBIO_NEW(fmat_t); uint_t i,j; s->height = height; diff --git a/src/fvec.c b/src/fvec.c index e62810e7..80a50e33 100644 --- a/src/fvec.c +++ b/src/fvec.c @@ -22,6 +22,9 @@ #include "fvec.h" fvec_t * new_fvec( uint_t length) { + if ((sint_t)length <= 0) { + return NULL; + } fvec_t * s = AUBIO_NEW(fvec_t); s->length = length; s->data = AUBIO_ARRAY(smpl_t, s->length); diff --git a/src/lvec.c b/src/lvec.c index cab68021..69d0f036 100644 --- a/src/lvec.c +++ b/src/lvec.c @@ -22,6 +22,9 @@ #include "lvec.h" lvec_t * new_lvec( uint_t length) { + if ((sint_t)length <= 0) { + return NULL; + } lvec_t * s = AUBIO_NEW(lvec_t); s->length = length; s->data = AUBIO_ARRAY(lsmp_t, s->length);