Coverity: Uninit: CID 400
[sxemacs] / src / emacs.c
index 21a46ab..3ac6f2e 100644 (file)
@@ -2504,7 +2504,7 @@ Do not call this.  It will reinitialize your SXEmacs.  You'll be sorry.
       (int nargs, Lisp_Object * args))
 {
        int ac;
-       const Extbyte *wampum;
+       const Extbyte *wampum = NULL;
        int namesize;
        int total_len;
        Lisp_Object orig_invoc_name = Fcar(Vcommand_line_args);
@@ -2521,13 +2521,20 @@ Do not call this.  It will reinitialize your SXEmacs.  You'll be sorry.
 
        TO_EXTERNAL_FORMAT(LISP_STRING, orig_invoc_name,
                           ALLOCA, (wampum, namesize), Qnative);
+       if ( wampum == NULL )
+               error("Could not transcode invocation name");
+
        namesize++;
 
        for (ac = 0, total_len = namesize; ac < nargs; ac++) {
                CHECK_STRING(args[ac]);
+               wampum_all[ac]=NULL;
                TO_EXTERNAL_FORMAT(LISP_STRING, args[ac],
                                   ALLOCA, (wampum_all[ac], wampum_all_len[ac]),
                                   Qnative);
+               if(wampum_all[ac]==NULL) {
+                       error("Could not transcode arguments");
+               }
                wampum_all_len[ac]++;
                total_len += wampum_all_len[ac];
        }
@@ -3039,8 +3046,8 @@ split_string_by_emchar_1(const Bufbyte * string, Bytecount size, Emchar sepchar)
    (':' or whatever).  */
 Lisp_Object decode_path(/*const*/ char *path)
 {
-       Bytecount newlen;
-       Bufbyte *newpath;
+       Bytecount newlen = 0;
+       Bufbyte *newpath = NULL;
        if (!path)
                return Qnil;
 
@@ -3051,7 +3058,7 @@ Lisp_Object decode_path(/*const*/ char *path)
           decode_env_path(), but it looks dubious here.  Does any code
           depend on decode_path("") returning nil instead of an empty
           string?  */
-       if (!newlen)
+       if (!newlen || !newpath)
                return Qnil;
 
        return split_string_by_emchar_1(newpath, newlen, SEPCHAR);
@@ -3112,24 +3119,23 @@ Non-nil return value means SXEmacs is running without interactive terminal.
        return noninteractive ? Qt : Qnil;
 }
 
+#ifdef USE_ASSERTIONS
+static int in_assert_failed = 0;
+static const char *assert_failed_file = NULL;
+static int assert_failed_line = 0;
+static const char *assert_failed_expr = NULL;
 /* This flag is useful to define if you're under a debugger; this way, you
    can put a breakpoint of assert_failed() and debug multiple problems
    in one session without having to recompile. */
-/* #define ASSERTIONS_DONT_ABORT */
-
-#ifdef USE_ASSERTIONS
-/* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */
-
-static int in_assert_failed;
-static const char *assert_failed_file;
-static int assert_failed_line;
-static const char *assert_failed_expr;
+static int assertions_dont_abort = 0;
 
 #ifdef fprintf
 #undef fprintf
 #endif
 
+#ifdef abort
 #undef abort                   /* avoid infinite #define loop... */
+#endif
 
 #define enter_debugger()
 
@@ -3150,18 +3156,21 @@ assert_failed(const char *file, int line, const char *expr)
                _exit(-1);
        else if (in_assert_failed == 3) {
                enter_debugger();
-               _exit(-1);
+               abort();
        } else if (in_assert_failed == 2) {
                /* Not stderr_out(), which does additional things and may trigger
                   a recursive assertion failure.  fprintf was undeffed above, in
                   case it was encapsulated. */
                fprintf(stderr,
-                       "\nFatal error: recursive assertion failure, "
+                       "\n\nFatal error: recursive assertion failure, "
                        "file %s, line %d, %s\n", file, line, expr);
                fprintf(stderr,
                        "Original assertion failure: file %s, line %d, %s\n",
                        assert_failed_file, assert_failed_line,
                        assert_failed_expr);
+               fflush(stderr);
+               enter_debugger();
+               debug_short_backtrace(0x7FFF);
        } else {
                assert_failed_file = file;
                assert_failed_line = line;
@@ -3175,13 +3184,13 @@ assert_failed(const char *file, int line, const char *expr)
                        stderr_out
                            ("\nFatal error: assertion failed, file %s, line %d, %s\n",
                             file, line, expr);
+               fflush(stderr);
+               enter_debugger();
+               debug_backtrace();
+       }
+       if (! assertions_dont_abort) {
+               abort();
        }
-       fflush(stderr);
-
-       enter_debugger();
-#if !defined (ASSERTIONS_DONT_ABORT)
-       abort();
-#endif
        inhibit_non_essential_printing_operations = 0;
        in_assert_failed = 0;
 }