If I do a substring operation where I extract the middle of a string, I occasionally get results that are not correct. Example code: $var(x) = $(var(y){s.substr,1,5});
This seems to be the same issue as: http://sip-router.1086192.n5.nabble.com/PATCH-Memory-corruption-using-s-subs...
This issue had a fix which added "tr_string_clone_result" in numerous exit points in pv_trans.c: https://github.com/kamailio/kamailio/commit/fe7e4a5152674aa9c81c09dd2fc9938d...
It seemed to be missing at the exit path for the substring operation which may explain my observation. See: https://github.com/kamailio/kamailio/blob/master/src/modules/pv/pv_trans.c#L...
I also notice that this is not used in some other string operations which leads me to wonder if this problem is more prevalent (likely, since I've heard reports of similar symptoms with the replace).
Suggestion: Investigate if we can have this "tr_string_clone_result" called here and remove all other occurrences in the switch clause.
Thank you, can you try with the patch 280eabf1 and report back the result? I will then backport it to the stable branches as well.
I am on 4.x, will test that
Will you be patching other string operations?
The other string operation had already this function call, so I think they should work already. (Some of the functions works also in-place, and not need it).
In preparations for releasing 5.2.3, I backported the referred patch to branch 5.2 with commit 4676d3d2c1267761ac6405464459b49c809afcbf .
If needed for 5.1, it will be backported before its next release (or someone else can do it right away).
So I am closing this issue, but if still not working as expected, then reopen.
Closed #1937.
Thank you Daniel, I just backported as well to 5.1 branch.