[svn-commits] kmoore: branch group/media_formats-reviewed-trunk r418395 - /team/group/media...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 11 16:01:55 CDT 2014


Author: kmoore
Date: Fri Jul 11 16:01:48 2014
New Revision: 418395

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418395
Log:
media formats: Fix double unref on full cache

If the frame cache on a thread is full, the format on a frame will be
double-unreffed. This fixes the double-unref by making sure the first
unref only occurs if the frame actually goes into the TLS frame cache.

Review: https://reviewboard.asterisk.org/r/3746/

Modified:
    team/group/media_formats-reviewed-trunk/main/frame.c

Modified: team/group/media_formats-reviewed-trunk/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/frame.c?view=diff&rev=418395&r1=418394&r2=418395
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/frame.c (original)
+++ team/group/media_formats-reviewed-trunk/main/frame.c Fri Jul 11 16:01:48 2014
@@ -126,13 +126,13 @@
 		/* Cool, only the header is malloc'd, let's just cache those for now
 		 * to keep things simple... */
 		struct ast_frame_cache *frames;
-		if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
-			(fr->frametype == AST_FRAME_IMAGE)) {
-			ao2_cleanup(fr->subclass.format);
-		}
-
 		if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames))) &&
 		    (frames->size < FRAME_CACHE_MAX_SIZE)) {
+			if ((fr->frametype == AST_FRAME_VOICE) || (fr->frametype == AST_FRAME_VIDEO) ||
+				(fr->frametype == AST_FRAME_IMAGE)) {
+				ao2_cleanup(fr->subclass.format);
+			}
+
 			AST_LIST_INSERT_HEAD(&frames->list, fr, frame_list);
 			frames->size++;
 			return;




More information about the svn-commits mailing list