Browse code

tm: free new tm cell in case of error if it was not referenced

- part of t_uac_prepare(), reported by GH #1554

(cherry picked from commit f94770840029c1c73ab129f4b71fcb0cf146d808)
(cherry picked from commit 3da0bcb4b4e27d115a2d6eb47cd0cebc33d34a61)

Daniel-Constantin Mierla authored on 06/06/2018 08:24:18
Showing 1 changed files
... ...
@@ -575,11 +575,18 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
575 575
 
576 576
 error2:
577 577
 #ifdef TM_DEL_UNREF
578
-	if (!is_ack) {
579
-		UNREF_FREE(new_cell);
580
-	}else
581
-#endif
578
+	if (is_ack) {
582 579
 		free_cell(new_cell);
580
+	} else {
581
+		if(atomic_get_int(&new_cell->ref_count)==0) {
582
+			free_cell(new_cell);
583
+		} else {
584
+			UNREF_FREE(new_cell);
585
+		}
586
+	}
587
+#else
588
+	free_cell(new_cell);
589
+#endif
583 590
 error3:
584 591
 	return ret;
585 592
 }