Browse code

core: Remove redundant check from (shm|pkg)_str_dup()

Check for src->s is also done before the memory allocation.

Alex Hermann authored on 20/10/2020 07:46:13
Showing 1 changed files
... ...
@@ -781,12 +781,6 @@ static inline int shm_str_dup(str* dst, const str* src)
781 781
 		return -1;
782 782
 	}
783 783
 
784
-	/* avoid memcpy from NULL source - undefined behaviour */
785
-	if (src->s == NULL) {
786
-		LM_WARN("shm_str_dup fallback; skip memcpy for src->s == NULL\n");
787
-		return 0;
788
-	}
789
-
790 784
 	memcpy(dst->s, src->s, dst->len);
791 785
 
792 786
 	return 0;
... ...
@@ -881,12 +875,6 @@ static inline int pkg_str_dup(str* dst, const str* src)
881 875
 		return -1;
882 876
 	}
883 877
 
884
-	/* avoid memcpy from NULL source - undefined behaviour */
885
-	if (src->s == NULL) {
886
-		LM_WARN("pkg_str_dup fallback; skip memcpy for src->s == NULL\n");
887
-		return 0;
888
-	}
889
-
890 878
 	memcpy(dst->s, src->s, dst->len);
891 879
 
892 880
 	return 0;