Fixed bug #50219 (soap call Segmentation fault on a redirected url).
authorPierrick Charron <pierrick@php.net>
Sat, 21 Nov 2009 01:22:32 +0000 (01:22 +0000)
committerPierrick Charron <pierrick@php.net>
Sat, 21 Nov 2009 01:22:32 +0000 (01:22 +0000)
ext/soap/php_http.c

index dae863a4c790a099843995cb03d67fff8c3f8fd8..0207cf7cc1357dcee9e096cf8adcf0699e9d0104 100644 (file)
@@ -996,12 +996,20 @@ try_again:
                                        new_url->host = phpurl->host ? estrdup(phpurl->host) : NULL;
                                        new_url->port = phpurl->port;
                                        if (new_url->path && new_url->path[0] != '/') {
-                                               char *t = phpurl->path;
-                                               char *p = strrchr(t, '/');
-                                               if (p) {
-                                                       char *s = emalloc((p - t) + strlen(new_url->path) + 2);
-                                                       strncpy(s, t, (p - t) + 1);
-                                                       s[(p - t) + 1] = 0;
+                                               if (phpurl->path) {
+                                                       char *t = phpurl->path;
+                                                       char *p = strrchr(t, '/');
+                                                       if (p) {
+                                                               char *s = emalloc((p - t) + strlen(new_url->path) + 2);
+                                                               strncpy(s, t, (p - t) + 1);
+                                                               s[(p - t) + 1] = 0;
+                                                               strcat(s, new_url->path);
+                                                               efree(new_url->path);
+                                                               new_url->path = s;
+                                                       } 
+                                               } else {
+                                                       char *s = emalloc(strlen(new_url->path) + 2);
+                                                       s[0] = '/'; s[1] = 0;
                                                        strcat(s, new_url->path);
                                                        efree(new_url->path);
                                                        new_url->path = s;