### Description
I have compiled Kamailio with google ASAN module and faced issue where the string PV with NULL value cannot be copied. Using GDB I found this function call triggers error when Google ASAN is used, `value->s.s = NULL`, `value->s.len = 0` ``` memcpy(var->v.value.s.s, value->s.s, value->s.len); ``` [Link](https://github.com/kamailio/kamailio/blob/caccb13e29ee12166c8101efa0d5ab2745...) This happens only when ASAN is used. Without ASAN same function call with the same values does not trigger an error.
In my test case this function called from [`lost/functions.c:1285`](https://github.com/kamailio/kamailio/blob/caccb13e29ee12166c8101efa0d5ab2745...)
To compile with asan used extra flags ``` -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment ```
### Troubleshooting #### Log Messages ``` 0(913407) INFO: {1 1 INVITE 1-455779@172.21.0.84} lost [functions.c:891]: lost_function(): ### LOST urn [urn:sip:911@3.236.25.254:5060] 0(913407) INFO: {1 1 INVITE 1-455779@172.21.0.84} lost [functions.c:983]: lost_function(): ### LOST loc [112233445566@jim.com] 0(913407) ERROR: {1 1 INVITE 1-455779@172.21.0.84} lost [utilities.c:336]: lost_get_content(): could not get XML node content pv_svar.c:137:3: runtime error: null pointer passed as argument 2, which is declared to never be null ``` ### Additional Information
* **Kamailio Version** - output of `kamailio -v`
current master, test 375f86b69e11cf835ae919873d3cd56f32d589c8
* **Operating System**:
Centos 8
This error triggered by `-fsanitize=undefined` ASAN options. When used `-fno-sanitize=undefined`, then this error does not rize.
I do not understand where need to fix this. This is required to fix inside `pv` module (a more general approach for all modules) or inside `lost` module.
I added a safety check in pv module (6eb67eaa4fc27d1eb7da7b2b674ffe8e7f86ecbc) although would be probably good that the code willing to set a $var() does not set the type of value is string if it's provided as NULL
I have tested this commit. Now error does not happen.
I will try to update also module lost.
Thanks for testing!
Closed #2913.