diff options
| author | Nakidai <nakidai@disroot.org> | 2024-10-25 15:06:36 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2024-10-25 15:11:34 +0300 |
| commit | f5d44483e1be84679cc529704c73fcfdfc32fab2 (patch) | |
| tree | c6ecf89171985f55e53b2ddd746f09ad4ff4ca93 | |
| parent | 95493a89a2f82e8f13576e912dc99d3451521c21 (diff) | |
| download | througha-f5d44483e1be84679cc529704c73fcfdfc32fab2.tar.gz througha-f5d44483e1be84679cc529704c73fcfdfc32fab2.zip | |
Since third part of for loop is executed before the second one, `get_envname` function was trying to copy from NULL at the end of env vector every run.
| -rw-r--r-- | througha.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/througha.c b/througha.c index 1d0c3d5..d5cf71c 100644 --- a/througha.c +++ b/througha.c @@ -21,8 +21,12 @@ void usage(const char *name, const char *message) size_t get_envname(char *dest, const char *var) { size_t i = 0; + + if (dest == NULL || var == NULL) return 0; + while ((dest[i] = tolower(var[i])) != '=') ++i; dest[i] = '\0'; + return i; } |