Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

###Bug###

Bug

This line:

 argv_copy[argc] = (char *) NULL;

should be:

 argv_copy[argc-1] = NULL;

You are removing one argument so you need to terminate the array at the right place.

###Copy unneeded###

Copy unneeded

Instead of:

 execvp(argv[1], argv_copy);

you could do:

 execvp(argv[1], &argv[1]);

and avoid making a copy.

###Bug###

This line:

 argv_copy[argc] = (char *) NULL;

should be:

 argv_copy[argc-1] = NULL;

You are removing one argument so you need to terminate the array at the right place.

###Copy unneeded###

Instead of:

 execvp(argv[1], argv_copy);

you could do:

 execvp(argv[1], &argv[1]);

and avoid making a copy.

Bug

This line:

 argv_copy[argc] = (char *) NULL;

should be:

 argv_copy[argc-1] = NULL;

You are removing one argument so you need to terminate the array at the right place.

Copy unneeded

Instead of:

 execvp(argv[1], argv_copy);

you could do:

 execvp(argv[1], &argv[1]);

and avoid making a copy.

Source Link
JS1
  • 28.8k
  • 3
  • 41
  • 83

###Bug###

This line:

 argv_copy[argc] = (char *) NULL;

should be:

 argv_copy[argc-1] = NULL;

You are removing one argument so you need to terminate the array at the right place.

###Copy unneeded###

Instead of:

 execvp(argv[1], argv_copy);

you could do:

 execvp(argv[1], &argv[1]);

and avoid making a copy.

lang-c

AltStyle によって変換されたページ (->オリジナル) /