From 509593fc49227220bbda3d2f18b137bdf467a75d Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 14 Feb 2008 18:17:02 +0000 Subject: [PATCH] sync w/ libteletone changes from main repo git-svn-id: http://svn.openzap.org/svn/openzap/trunk@394 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/include/libteletone.h | 9 +++++++++ libs/freetdm/src/libteletone_detect.c | 2 ++ libs/freetdm/src/libteletone_generate.c | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/src/include/libteletone.h b/libs/freetdm/src/include/libteletone.h index aaf7b0ed47..db6accb97e 100644 --- a/libs/freetdm/src/include/libteletone.h +++ b/libs/freetdm/src/include/libteletone.h @@ -74,6 +74,9 @@ #ifdef __cplusplus extern "C" { #endif + +#include + #define TELETONE_MAX_DTMF_DIGITS 128 #define TELETONE_MAX_TONES 6 #define TELETONE_TONE_RANGE 127 @@ -101,6 +104,12 @@ typedef struct { typedef __int16 int16_t; #endif +#if (_MSC_VER >= 1400) // VC8+ +#define teletone_assert(expr) assert(expr);__analysis_assume( expr ) +#else +#define teletone_assert(expr) assert(expr) +#endif + #include #include diff --git a/libs/freetdm/src/libteletone_detect.c b/libs/freetdm/src/libteletone_detect.c index 7bbdd697df..55cfcf60cd 100644 --- a/libs/freetdm/src/libteletone_detect.c +++ b/libs/freetdm/src/libteletone_detect.c @@ -432,6 +432,8 @@ int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, char *buf, int max) { + teletone_assert(dtmf_detect_state->current_digits <= TELETONE_MAX_DTMF_DIGITS); + if (max > dtmf_detect_state->current_digits) { max = dtmf_detect_state->current_digits; } diff --git a/libs/freetdm/src/libteletone_generate.c b/libs/freetdm/src/libteletone_generate.c index fdf4dd14f7..7771188c46 100644 --- a/libs/freetdm/src/libteletone_generate.c +++ b/libs/freetdm/src/libteletone_generate.c @@ -191,10 +191,13 @@ static int ensure_buffer(teletone_generation_session_t *ts, int need) need *= ts->channels; if (need > ts->datalen) { + teletone_audio_t *tmp; ts->datalen = need + ts->dynamic; - if (!(ts->buffer = realloc(ts->buffer, ts->datalen))) { + tmp = realloc(ts->buffer, ts->datalen); + if (!tmp) { return -1; } + ts->buffer = tmp; } return 0;