Skip to content

Commit

Permalink
fix(util): ParseUrl() parsing result is incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Oct 7, 2019
1 parent de40c7c commit 3f9450c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,15 @@ LCUI_BOOL ParseUrl(LCUI_Style s, const char *str, const char *dirname)
s->type = LCUI_STYPE_STRING;
if (dirname && !IsAbsolutePath(head)) {
n += (dirname_len = strlen(dirname));
s->val_string = malloc((n + 1) * sizeof(char));
s->val_string = malloc((n + 2) * sizeof(char));
if (!s->val_string) {
return FALSE;
}
strcpy(s->val_string, dirname);
if (s->val_string[dirname_len - 1] != '/') {
s->val_string[dirname_len] = '/';
dirname_len += 1;
n += 1;
}
strncpy(s->val_string + dirname_len,
head, n - dirname_len);
Expand Down

0 comments on commit 3f9450c

Please sign in to comment.