Merged revisions 321273 via svnmerge from
[asterisk/asterisk.git] / channels / sip / reqresp_parser.c
index 6cab6f1..6c70317 100644 (file)
@@ -42,25 +42,29 @@ int parse_uri_full(char *uri, const char *scheme, char **user, char **pass,
        char *c = NULL;
        int error = 0;
 
+       /*
+        * Initialize requested strings - some functions don't care if parse_uri fails
+        * and will attempt to use string pointers passed into parse_uri even after a
+        * parse_uri failure
+        */
+       if (user) {
+               *user = "";
+       }
+       if (pass) {
+               *pass = "";
+       }
+       if (domain) {
+               *domain = "";
+       }
+       if (headers) {
+               *headers = "";
+       }
+       if (residue) {
+               *residue = "";
+       }
+
        /* check for valid input */
        if (ast_strlen_zero(uri)) {
-               /* make sure we leave nothing undefined after we exit */
-               if (user) {
-                       *user = "";
-               }
-               if (pass) {
-                       *pass = "";
-               }
-               if (domain) {
-                       *domain = "";
-               }
-               if (headers) {
-                       *headers = "";
-               }
-               if (residue) {
-                       *residue = "";
-               }
-
                return -1;
        }