summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-26 14:13:08 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-26 14:13:08 -0400
commitc51851396d81e08011bc4d37f7f096e753cc05cb (patch)
tree15ba26aae9ae10da06e1de9408fe388e075fc121 /git.c
parentabba51f80a0c86684d4e7baf30b16c80fe0820ef (diff)
Added some more error checking in `create_info()`.
Diffstat (limited to 'git.c')
-rw-r--r--git.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/git.c b/git.c
index 9632d21..3c84378 100644
--- a/git.c
+++ b/git.c
@@ -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);