You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2012/05/21 22:28:06 UTC

svn commit: r1341193 - in /apr/apr/trunk/include: apr_pools.h apr_strings.h

Author: sf
Date: Mon May 21 20:28:05 2012
New Revision: 1341193

URL: http://svn.apache.org/viewvc?rev=1341193&view=rev
Log:
add attribute alloc_size to a few functions
    
This allows gcc's -D_FORTIFY_SOURCE=2 to do some overflow checks

Modified:
    apr/apr/trunk/include/apr_pools.h
    apr/apr/trunk/include/apr_strings.h

Modified: apr/apr/trunk/include/apr_pools.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_pools.h?rev=1341193&r1=1341192&r2=1341193&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_pools.h (original)
+++ apr/apr/trunk/include/apr_pools.h Mon May 21 20:28:05 2012
@@ -401,6 +401,9 @@ APR_DECLARE(void) apr_pool_destroy_debug
  * @return The allocated memory
  */
 APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+                    __attribute__((alloc_size(2)))
+#endif
                     __attribute__((nonnull(1)));
 
 /**
@@ -413,6 +416,9 @@ APR_DECLARE(void *) apr_palloc(apr_pool_
  */
 APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size,
                                      const char *file_line)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+                    __attribute__((alloc_size(2)))
+#endif
                     __attribute__((nonnull(1)));
 
 #if APR_POOL_DEBUG

Modified: apr/apr/trunk/include/apr_strings.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_strings.h?rev=1341193&r1=1341192&r2=1341193&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_strings.h (original)
+++ apr/apr/trunk/include/apr_strings.h Mon May 21 20:28:05 2012
@@ -106,7 +106,11 @@ APR_DECLARE(char *) apr_pstrdup(apr_pool
  *         has 'n' or more characters.  If the string might contain
  *         fewer characters, use apr_pstrndup.
  */
-APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n);
+APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+    __attribute__((alloc_size(3)))
+#endif
+    ;
 
 /**
  * Duplicate at most n characters of a string into memory allocated 
@@ -128,7 +132,11 @@ APR_DECLARE(char *) apr_pstrndup(apr_poo
  * @param n The number of bytes to duplicate
  * @return The new block of memory
  */
-APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n);
+APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n)
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+    __attribute__((alloc_size(3)))
+#endif
+    ;
 
 /**
  * Concatenate multiple strings, allocating memory out a pool