diff --git a/doc/APIchanges b/doc/APIchanges
index 990e36e5c0aaf8d951d65e9e8b5ef0c9f1f3d08e..cad5a3a3122d8b531a54058a6293b0080ab354ba 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-07-10 - xxxxxxx - lavu 51.37.0
+  Add av_malloc_array() and av_mallocz_array()
+
 2012-06-22 - xxxxxxx - lavu 51.34.0
   Add av_usleep()
 
diff --git a/libavutil/mem.h b/libavutil/mem.h
index cd8490b2dae9e885f79921da9693c28f9ed20abd..211d33f64f19909dd3469fa8c1dd5b5a24bd0b78 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -63,9 +63,9 @@
 #endif
 
 #if AV_GCC_VERSION_AT_LEAST(4,3)
-    #define av_alloc_size(n) __attribute__((alloc_size(n)))
+    #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
 #else
-    #define av_alloc_size(n)
+    #define av_alloc_size(...)
 #endif
 
 /**
@@ -78,6 +78,22 @@
  */
 void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
 
+/**
+ * Helper function to allocate a block of size * nmemb bytes with
+ * using av_malloc()
+ * @param nmemb Number of elements
+ * @param size Size of the single element
+ * @return Pointer to the allocated block, NULL if the block cannot
+ * be allocated.
+ * @see av_malloc()
+ */
+av_alloc_size(1,2) static inline void *av_malloc_array(size_t nmemb, size_t size)
+{
+    if (size <= 0 || nmemb >= INT_MAX / size)
+        return NULL;
+    return av_malloc(nmemb * size);
+}
+
 /**
  * Allocate or reallocate a block of memory.
  * If ptr is NULL and size > 0, allocate a new block. If
@@ -112,6 +128,23 @@ void av_free(void *ptr);
  */
 void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
 
+/**
+ * Helper function to allocate a block of size * nmemb bytes with
+ * using av_mallocz()
+ * @param nmemb Number of elements
+ * @param size Size of the single element
+ * @return Pointer to the allocated block, NULL if the block cannot
+ * be allocated.
+ * @see av_mallocz()
+ * @see av_malloc_array()
+ */
+av_alloc_size(1,2) static inline void *av_mallocz_array(size_t nmemb, size_t size)
+{
+    if (size <= 0 || nmemb >= INT_MAX / size)
+        return NULL;
+    return av_mallocz(nmemb * size);
+}
+
 /**
  * Duplicate the string s.
  * @param s string to be duplicated
diff --git a/libavutil/version.h b/libavutil/version.h
index c42c6b0bc4111a289c09a707f696d057c9993cb4..f55a99fd48b46eca3a45efb16d37edd68463f1d0 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -37,7 +37,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 36
+#define LIBAVUTIL_VERSION_MINOR 37
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \