Skip to content

Commit 23d1e49

Browse files
committed
net_http_urlencode_full - exit out of the loop after the last slash
isntead of always iterating over it 3 times
1 parent 6775559 commit 23d1e49

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libretro-common/net/net_http.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,16 @@ void net_http_urlencode_full(char *s, const char *source, size_t len)
328328
size_t tmp_len;
329329
char url_domain[256];
330330
char url_path[PATH_MAX_LENGTH];
331-
char *tmp = NULL;
332-
int count = 0;
331+
int count = 0;
332+
char *tmp = url_path;
333333

334334
strlcpy(url_path, source, sizeof(url_path));
335-
tmp = url_path;
336335

337336
while (count < 3 && tmp[0] != '\0')
338337
{
339338
tmp = strchr(tmp, '/');
339+
if (!tmp)
340+
break;
340341
count++;
341342
tmp++;
342343
}

0 commit comments

Comments
 (0)