From: Tilghman Lesher Date: Fri, 9 Jan 2009 18:30:55 +0000 (+0000) Subject: When using ast_str with a non-ast_str-enabled API, we need to update the buffer X-Git-Tag: 1.6.2.0-beta1~480 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a9e8078b9733b572795ed8c208c45dd35e50bb0;p=thirdparty%2Fasterisk.git When using ast_str with a non-ast_str-enabled API, we need to update the buffer or otherwise, we cannot use ast_str_strlen(). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@168090 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 529456c987..bf3cf32363 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -403,6 +403,16 @@ void ast_str_reset(struct ast_str *buf), } ) +/*! \brief Update the length of the buffer, after using ast_str merely as a buffer. + * \param buf A pointer to the ast_str string. + */ +AST_INLINE_API( +void ast_str_update(struct ast_str *buf), +{ + buf->__AST_STR_USED = strlen(buf->__AST_STR_STR); +} +) + /*! \brief Trims trailing whitespace characters from an ast_str string. * \param buf A pointer to the ast_str string. */ diff --git a/res/res_agi.c b/res/res_agi.c index 926d4d95bc..6151549e30 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1861,6 +1861,7 @@ static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **arg do { res = ast_db_get(argv[2], argv[3], ast_str_buffer(buf), ast_str_size(buf)); + ast_str_update(buf); if (ast_str_strlen(buf) < ast_str_size(buf) - 1) { break; }