[Pkg-wmaker-commits] [wmtime] 59/101: wmgeneral: Check if malloc fails.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:59:29 UTC 2015


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

dtorrance-guest pushed a commit to branch master
in repository wmtime.

commit a655d80ca40cec46260a554a25fff047005dc38d
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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/wmgeneral/misc.c b/wmgeneral/misc.c
index c36cdb4..cdaf7e0 100644
--- a/wmgeneral/misc.c
+++ b/wmgeneral/misc.c
@@ -16,11 +16,12 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #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/wmtime.git



More information about the Pkg-wmaker-commits mailing list