|
@@ -68,7 +68,10 @@ asmsh_env_t* asmsh_env(const char *childpath)
|
68
|
68
|
|
69
|
69
|
return res;
|
70
|
70
|
err:
|
71
|
|
- free(res->childpath);
|
|
71
|
+ if(res->childpath)
|
|
72
|
+ {
|
|
73
|
+ free(res->childpath);
|
|
74
|
+ }
|
72
|
75
|
err_pathdup:
|
73
|
76
|
free(res);
|
74
|
77
|
errno = err;
|
|
@@ -266,6 +269,11 @@ static int _asmsh_env_spawn(asmsh_env_t *env)
|
266
|
269
|
|
267
|
270
|
const char *childpath = env->childpath?env->childpath:asmsh_env_tmpexec();
|
268
|
271
|
|
|
272
|
+ if(!childpath)
|
|
273
|
+ {
|
|
274
|
+ return -1; // Error in asmsh_env_tmpexec()
|
|
275
|
+ }
|
|
276
|
+
|
269
|
277
|
if((env->pid = fork()) == -1)
|
270
|
278
|
{
|
271
|
279
|
err = errno;
|
|
@@ -422,7 +430,17 @@ static void _asmsh_env_child(const char *childpath)
|
422
|
430
|
static char *asmsh_env_tmpexec()
|
423
|
431
|
{
|
424
|
432
|
char *ret = strdup("asmsh_child_XXXXXXXXX");
|
|
433
|
+ if(!ret)
|
|
434
|
+ {
|
|
435
|
+ perror("getting a temporary file name");
|
|
436
|
+ return NULL;
|
|
437
|
+ }
|
425
|
438
|
int tmpfd = mkstemp(ret);
|
|
439
|
+ if(tmpfd < 0)
|
|
440
|
+ {
|
|
441
|
+ perror("Unable to mk temporary file");
|
|
442
|
+ return NULL;
|
|
443
|
+ }
|
426
|
444
|
const int sz = &_binary_child_end - &_binary_child_start;
|
427
|
445
|
int rsz = write(tmpfd, &_binary_child_start, sz);
|
428
|
446
|
if(rsz<sz)
|