aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xs_url.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/xs_url.h b/xs_url.h
index ef35a4b..e25c73b 100644
--- a/xs_url.h
+++ b/xs_url.h
@@ -289,9 +289,6 @@ xs_dict *xs_multipart_form_data(const char *payload, int p_size, const char *hea
po = p - payload;
ps = q - p - 2; /* - 2 because the final \r\n */
- if (ps <= 0)
- break;
-
/* is it a filename? */
if (fn != NULL) {
/* p_var value is a list */
@@ -315,12 +312,14 @@ xs_dict *xs_multipart_form_data(const char *payload, int p_size, const char *hea
}
else {
/* regular variable; just copy */
- xs *vc = xs_realloc(NULL, ps + 1);
- memcpy(vc, payload + po, ps);
- vc[ps] = '\0';
+ if (ps > 0) {
+ xs *vc = xs_realloc(NULL, ps + 1);
+ memcpy(vc, payload + po, ps);
+ vc[ps] = '\0';
- if (xs_is_string(vn) && xs_is_string(vc))
- p_vars = xs_dict_append(p_vars, vn, vc);
+ if (xs_is_string(vn) && xs_is_string(vc))
+ p_vars = xs_dict_append(p_vars, vn, vc);
+ }
}
/* move on */