[Pkg-wmaker-commits] [wmmon] 14/38: wmgeneral: Check if malloc fails.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Sat Aug 12 22:43:07 UTC 2017
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository wmmon.
commit e20f036225ac80889bb25960c3a19fa6645be4cf
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/wmmon.git
More information about the Pkg-wmaker-commits
mailing list