[Pkg-wmaker-commits] [wmitime] 01/18: wmgeneral: Check if malloc fails.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Aug 22 01:36:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository wmitime.

commit 4ef877055fee33181ba13c64c03874445c4f1ceb
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Tue May 19 22:30:44 2015 -0500

    wmgeneral: Check if malloc fails.
    
    Fixes "(error) Uninitialized variable: ret" found by cppcheck.
---
 wmgeneral/misc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/wmgeneral/misc.c b/wmgeneral/misc.c
index 1f3bb2e..cdaf7e0 100644
--- a/wmgeneral/misc.c
+++ b/wmgeneral/misc.c
@@ -21,6 +21,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 #include "list.h"
 #include "misc.h"
 
@@ -63,6 +64,10 @@ next_token(char *word, char **next)
     int state, ctype;
 
     t = ret = malloc(strlen(word)+1);
+    if (ret == NULL) {
+	    fprintf(stderr, "Insufficient memory.\n");
+	    exit(EXIT_FAILURE);
+    }
     ptr = word;
 
     state = 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmitime.git



More information about the Pkg-wmaker-commits mailing list