Fix join_path_components() to not add a leading slash when joining to an

initial null string.

Per report from Robert Haas in testing psql \ir.
This commit is contained in:
Bruce Momjian 2011-11-26 09:27:11 -05:00
parent dea5f6cefe
commit fd6dbc24ef
1 changed files with 2 additions and 1 deletions

View File

@ -212,7 +212,8 @@ join_path_components(char *ret_path,
}
if (*tail)
snprintf(ret_path + strlen(ret_path), MAXPGPATH - strlen(ret_path),
"/%s", tail);
/* only add slash if there is something already in head */
"%s%s", head[0] ? "/" : "", tail);
}