History

make-process: memcpy instead of snprintf

Sigrid Solveig Haflínudóttir committed 2 months ago

Commit ea765e81 parent c9a23e51 file · +4 −2Browse files

Showing the changes to src (1 of 1 file). Show all

Unified · Split

src/process.c+4−2
@@ -186,9 +186,11 @@ BUILTIN("make-process", make_process) · 185 unmodified lines
186 bthrow(type_error("env", "assoc list", e));186 bthrow(type_error("env", "assoc list", e));
187 const char *ek = tostr(car_(pair)), *ev = tostr(cdr_(pair));187 const char *ek = tostr(car_(pair)), *ev = tostr(cdr_(pair));
188 int nk = strlen(ek), nv = strlen(ev), sz = nk+1+nv+1;188 int nk = strlen(ek), nv = strlen(ev), sz = nk+1+nv+1;
189 if((env[i] = MEM_ALLOC(nk+1+nv+1)) == nil)189 if((env[i] = MEM_ALLOC(sz)) == nil)
190 bthrow(error(sl_errmem, "no memory for env[%d]", i));190 bthrow(error(sl_errmem, "no memory for env[%d]", i));
191 snprintf(env[i], sz, "%s=%s", ek, ev);191 memcpy(env[i], ek, nk);
192 env[i][nk] = '=';
193 memcpy(env[i]+nk+1, ev, nv+1);
192 }194 }
193 env[ne] = nil;195 env[ne] = nil;
194 }196 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t