From 21d7a208954084b97ee85594f9a3956c88028dc1 Mon Sep 17 00:00:00 2001 From: buslov Date: Tue, 31 Oct 2017 21:55:32 +0300 Subject: [PATCH] Fix V522 warning from PVS-Studio Static Analyzer There might be dereferencing of a potential null pointer --- cvsps.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cvsps.c b/cvsps.c index 981cd78..08b8812 100644 --- a/cvsps.c +++ b/cvsps.c @@ -1967,6 +1967,10 @@ CvsFileRevision * cvs_file_add_revision(CvsFile * file, const char * rev_str) if (!(rev = (CvsFileRevision*)get_hash_object(file->revisions, rev_str))) { rev = (CvsFileRevision*)calloc(1, sizeof(*rev)); + if (rev == NULL) + { + return (NULL); + } rev->rev = get_string(rev_str); rev->file = file; rev->branch = NULL; @@ -2083,6 +2087,10 @@ static PatchSet * create_patch_set() PatchSetMember * create_patch_set_member() { PatchSetMember * psm = (PatchSetMember*)calloc(1, sizeof(*psm)); + if (psm == NULL) + { + return (NULL); + } psm->pre_rev = NULL; psm->post_rev = NULL; psm->ps = NULL; @@ -2204,6 +2212,10 @@ void cvs_file_add_symbol(CvsFile * file, const char * rev_str, const char * p_ta if (!sym) { sym = (GlobalSymbol*)malloc(sizeof(*sym)); + if (sym == NULL) + { + return; + } sym->tag = tag_str; sym->ps = NULL; INIT_LIST_HEAD(&sym->tags);