[asterisk-commits] rmudgett: branch 10 r372656 - in /branches/10: ./ main/astmm.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 7 18:06:42 CDT 2012
Author: rmudgett
Date: Fri Sep 7 18:06:38 2012
New Revision: 372656
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372656
Log:
Fix MALLOC_DEBUG version of ast_strndup().
(closes issue ASTERISK-20349)
Reported by: Brent Eagles
........
Merged revisions 372655 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/main/astmm.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/main/astmm.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/astmm.c?view=diff&rev=372656&r1=372655&r2=372656
==============================================================================
--- branches/10/main/astmm.c (original)
+++ branches/10/main/astmm.c Fri Sep 7 18:06:38 2012
@@ -272,16 +272,17 @@
char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
{
size_t len;
- void *ptr;
-
- if (!s)
- return NULL;
-
- len = strlen(s) + 1;
- if (len > n)
- len = n;
- if ((ptr = __ast_alloc_region(len, FUNC_STRNDUP, file, lineno, func, 0)))
- strcpy(ptr, s);
+ char *ptr;
+
+ if (!s) {
+ return NULL;
+ }
+
+ len = strnlen(s, n);
+ if ((ptr = __ast_alloc_region(len + 1, FUNC_STRNDUP, file, lineno, func, 0))) {
+ memcpy(ptr, s, len);
+ ptr[len] = '\0';
+ }
return ptr;
}
More information about the asterisk-commits
mailing list