diff --git a/lib/chibi/disasm.c b/lib/chibi/disasm.c index 3a04b3c6..4f9c8493 100644 --- a/lib/chibi/disasm.c +++ b/lib/chibi/disasm.c @@ -15,7 +15,7 @@ static void sexp_write_pointer (sexp ctx, void *p, sexp out) { } static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) { - sexp tmp; + sexp tmp=NULL; unsigned char *ip, opcode, i; if (sexp_procedurep(bc)) { @@ -94,7 +94,7 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) { } sexp_write_char(ctx, '\n', out); if ((opcode == SEXP_OP_PUSH) && (depth < SEXP_DISASM_MAX_DEPTH) - && (sexp_bytecodep(tmp) || sexp_procedurep(tmp))) + && tmp && (sexp_bytecodep(tmp) || sexp_procedurep(tmp))) disasm(ctx, self, tmp, out, depth+1); if (ip - sexp_bytecode_data(bc) < sexp_bytecode_length(bc)) goto loop; diff --git a/lib/srfi/18/threads.c b/lib/srfi/18/threads.c index d8f0f865..1473d0e4 100644 --- a/lib/srfi/18/threads.c +++ b/lib/srfi/18/threads.c @@ -523,8 +523,10 @@ sexp sexp_scheduler (sexp ctx sexp_api_params(self, n), sexp root_thread) { /* either wait on an fd, or just sleep */ pollfds = sexp_global(res, SEXP_G_THREADS_POLL_FDS); if (sexp_portp(sexp_context_event(res)) && sexp_pollfdsp(pollfds)) { - if ((k = poll(sexp_pollfds_fds(pollfds), sexp_pollfds_num_fds(pollfds), usecs/1000)) > 0) + if ((k = poll(sexp_pollfds_fds(pollfds), sexp_pollfds_num_fds(pollfds), usecs/1000)) > 0) { + pfds = sexp_pollfds_fds(pollfds); goto unblock_io_threads; + } } else { usleep(usecs); sexp_context_waitp(res) = 0; diff --git a/lib/srfi/95/qsort.c b/lib/srfi/95/qsort.c index 14329e37..1d115720 100644 --- a/lib/srfi/95/qsort.c +++ b/lib/srfi/95/qsort.c @@ -203,6 +203,7 @@ static sexp sexp_sort_x (sexp ctx sexp_api_params(self, n), sexp seq, sexp_qsort(ctx, data, 0, len-1); if (sexp_opcodep(less) && sexp_opcode_inverse(less)) sexp_vector_nreverse(ctx, vec); + res = vec; } else if (! (sexp_procedurep(less) || sexp_opcodep(less))) { res = sexp_type_exception(ctx, self, SEXP_PROCEDURE, less); } else if (! (sexp_procedurep(key) || sexp_opcodep(key) || sexp_not(key))) { @@ -212,10 +213,8 @@ static sexp sexp_sort_x (sexp ctx sexp_api_params(self, n), sexp seq, } } - if (sexp_pairp(seq)) + if (sexp_pairp(seq) && ! sexp_exceptionp(res)) res = sexp_vector_copy_to_list(ctx, vec, seq); - else if (! sexp_exceptionp(res)) - res = vec; sexp_gc_release1(ctx); return res; diff --git a/main.c b/main.c index cbdd2bff..6128c538 100644 --- a/main.c +++ b/main.c @@ -110,7 +110,7 @@ static sexp sexp_load_standard_repl_env (sexp ctx, sexp env, sexp k) { void run_main (int argc, char **argv) { char *arg, *impmod, *p; - sexp env, out=SEXP_FALSE, res=SEXP_VOID, ctx=NULL; + sexp out=SEXP_FALSE, res=SEXP_VOID, env=NULL, ctx=NULL; sexp_sint_t i, j, len, quit=0, print=0, init_loaded=0; sexp_uint_t heap_size=0; sexp_gc_var2(tmp, args); diff --git a/sexp.c b/sexp.c index e77d6f04..0a662538 100644 --- a/sexp.c +++ b/sexp.c @@ -771,7 +771,7 @@ sexp sexp_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp sexp_string_concatenate_op (sexp ctx sexp_api_params(self, n), sexp str_ls, sexp sep) { sexp res, ls; sexp_uint_t len=0, i=0, sep_len=0; - char *p, *csep; + char *p, *csep=NULL; for (ls=str_ls; sexp_pairp(ls); ls=sexp_cdr(ls), i++) if (! sexp_stringp(sexp_car(ls))) return sexp_type_exception(ctx, self, SEXP_STRING, sexp_car(ls));