commit 5925e1f

grunfink  ·  2026-02-23 12:52:35 +0000 UTC
parent a8d907c
Fixed latest breakage in xs_multipart_form_data().
1 files changed,  +7, -8
+7, -8
 1@@ -289,9 +289,6 @@ xs_dict *xs_multipart_form_data(const char *payload, int p_size, const char *hea
 2         po = p - payload;
 3         ps = q - p - 2;     /* - 2 because the final \r\n */
 4 
 5-        if (ps <= 0)
 6-            break;
 7-
 8         /* is it a filename? */
 9         if (fn != NULL) {
10             /* p_var value is a list */
11@@ -315,12 +312,14 @@ xs_dict *xs_multipart_form_data(const char *payload, int p_size, const char *hea
12         }
13         else {
14             /* regular variable; just copy */
15-            xs *vc = xs_realloc(NULL, ps + 1);
16-            memcpy(vc, payload + po, ps);
17-            vc[ps] = '\0';
18+            if (ps > 0) {
19+                xs *vc = xs_realloc(NULL, ps + 1);
20+                memcpy(vc, payload + po, ps);
21+                vc[ps] = '\0';
22 
23-            if (xs_is_string(vn) && xs_is_string(vc))
24-                p_vars = xs_dict_append(p_vars, vn, vc);
25+                if (xs_is_string(vn) && xs_is_string(vc))
26+                    p_vars = xs_dict_append(p_vars, vn, vc);
27+            }
28         }
29 
30         /* move on */