X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftoe.c;h=6f45992f712416ceb837b6d7a4dbfb1194685ab9;hp=8af6f371b77b7adb5bb881338af79a5fe0f9b74e;hb=70322aa06a4a97ebff76d2869ad923cdf51ee0a9;hpb=11ca5f62994c7a14c4e500510bd242e1e721f8be diff --git a/progs/toe.c b/progs/toe.c index 8af6f371..6f45992f 100644 --- a/progs/toe.c +++ b/progs/toe.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -44,7 +44,7 @@ #include #endif -MODULE_ID("$Id: toe.c,v 1.51 2008/08/16 21:53:25 tom Exp $") +MODULE_ID("$Id: toe.c,v 1.52 2010/05/01 22:04:08 tom Exp $") #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, "..")) @@ -61,6 +61,13 @@ ExitProgram(int code) } #endif +static void +failed(const char *msg) +{ + perror(msg); + ExitProgram(EXIT_FAILURE); +} + #if USE_HASHED_DB static bool make_db_name(char *dst, const char *src, unsigned limit) @@ -184,10 +191,10 @@ typelist(int eargc, char *eargv[], DIRENT *entry; cwd_buf = typeRealloc(char, cwd_len, cwd_buf); - if (cwd_buf == 0) { - perror("realloc cwd_buf"); - continue; - } + if (cwd_buf == 0) + failed("realloc cwd_buf"); + + assert(cwd_buf != 0); strncpy(name_1, subdir->d_name, len)[len] = '\0'; if (isDotname(name_1)) @@ -480,6 +487,10 @@ main(int argc, char *argv[]) } if (!pass) { eargv = typeCalloc(char *, count + 1); + if (eargv == 0) + failed("realloc eargv"); + + assert(eargv != 0); } else { code = typelist((int) count, eargv, header, deschook); while (count-- > 0)