diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-26 14:13:08 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-26 14:13:08 -0400 |
commit | c51851396d81e08011bc4d37f7f096e753cc05cb (patch) | |
tree | 15ba26aae9ae10da06e1de9408fe388e075fc121 /git.c | |
parent | abba51f80a0c86684d4e7baf30b16c80fe0820ef (diff) |
Added some more error checking in `create_info()`.
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -69,11 +69,27 @@ pull_request *get_pull_request(int id, const char *root) { } int create_info(pull_request *pr, const char *pr_dir) { - int len = strlen(pr_dir) + strlen("/info"); - char *info = calloc(len+1, sizeof(char)); + int len; + int buf_len; + char *info; char *info_buf; FILE *fp; + /* Is the PR NULL? */ + if (pr == NULL) { + log(LOG_ERR,"Pull request is NULL."); + return 0; + } + /* Is the PR directory NULL? */ + if (pr_dir == NULL) { + log(LOG_ERR,"Pull request directory is NULL."); + return 0; + } + + len = strlen(pr_dir) + strlen("/info"); + buf_len = get_info_len(pr); + info = calloc(len+1, sizeof(char)); + /* Append /info to the PR directory. */ sprintf(info, "%s/info", pr_dir); |