diff --git a/shlr/spp/p/spp.h b/shlr/spp/p/spp.h index 742fc9e795..e895c347e5 100644 --- a/shlr/spp/p/spp.h +++ b/shlr/spp/p/spp.h @@ -74,9 +74,11 @@ TAG_CALLBACK(spp_getrandom) if (!echo[ifl]) { return 0; } - srandom (getpid()); // TODO: change this to be portable + srandom (getpid ()); // TODO: change this to be portable max = atoi (buf); - max = (int)(rand()%max); + if (max > 0) { + max = (int)(rand () % max); + } do_printf (out, "%d", max); return 0; } @@ -363,6 +365,7 @@ TAG_CALLBACK(spp_endpipe) pclose (spp_pipe_fd); } spp_pipe_fd = NULL; + free (str); return 0; } diff --git a/shlr/spp/spp.c b/shlr/spp/spp.c index da837a520e..856a5ec733 100644 --- a/shlr/spp/spp.c +++ b/shlr/spp/spp.c @@ -224,24 +224,7 @@ retry: do_fputs (out, ptr2 + delta); } else { D printf ("==> 3\n"); - if (ptr) { - lbuf_strcat (lbuf, ptr); - } else { - if (!lbuf) { - // XXX should never happen - fprintf (stderr, "syntax error?\n"); - return; - } - if (buf[0]) { - if (incmd) { - lbuf_strcat (lbuf, buf); - } else { - do_fputs (out, buf); - } - } else { - do_fputs (out, buf); - } - } + lbuf_strcat (lbuf, ptr); } }