diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-12-26 16:33:17 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-26 16:33:17 -0800 |
commit | 637210564a3ae22c7b3fb476a0334b61f43c95d1 (patch) | |
tree | bc30d61ccdb11928653f594c2989e42865c54418 /core/load-git.c | |
parent | 260ff50b0ad83b7404416b878e8a97550867875e (diff) | |
download | subsurface-637210564a3ae22c7b3fb476a0334b61f43c95d1.tar.gz |
Cleanup: avoid dereferencing NULL pointer
Coverity CID 208323
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/load-git.c')
-rw-r--r-- | core/load-git.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/core/load-git.c b/core/load-git.c index 6ddee4a54..5411eafcb 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -1578,16 +1578,18 @@ static int parse_picture_file(git_repository *repo, const git_tree_entry *entry, /* remember the picture data so we can handle it when all dive data has been loaded * the name of the git file is PIC-<hash> */ git_blob *blob = git_tree_entry_blob(repo, entry); - const void *rawdata = git_blob_rawcontent(blob); - int len = git_blob_rawsize(blob); - struct picture_entry_list *new_pel = malloc(sizeof(struct picture_entry_list)); - new_pel->next = pel; - pel = new_pel; - pel->data = malloc(len); - memcpy(pel->data, rawdata, len); - pel->len = len; - pel->hash = strdup(name + 4); - git_blob_free(blob); + if (blob) { + const void*rawdata = git_blob_rawcontent(blob); + int len = git_blob_rawsize(blob); + struct picture_entry_list *new_pel = malloc(sizeof(struct picture_entry_list)); + new_pel->next = pel; + pel = new_pel; + pel->data = malloc(len); + memcpy(pel->data, rawdata, len); + pel->len = len; + pel->hash = strdup(name + 4); + git_blob_free(blob); + } return 0; } |