On Mon, Mar 26, 2012 at 11:11:47PM +0200, Vincent Lefevre wrote:
> Something more complex, as
>
> echo | gnuplot -
>
> does not crash.
>
> FYI,
>
> $ echo "foo" | valgrind gnuplot -
> ==11357== Memcheck, a memory error detector
...
> A null pointer dereference?
> So, there seems to be a problem with com_line() while interactive
> is TRUE (and I wonder what the intent is...).
Just for the records,
I have been trying to track this "the dumb way" (putting messages here and
there) and seems that the problem is in a call to gp_get_string called
from read_line called from com_line (all in command.c).
I had no time to go further and do not know when I will have it. I am
attaching a diff with a minimal fprintf set around the problem.
Hope this helps,
--
Agustin
diff --git a/src/command.c b/src/command.c
index 2dcd600..4d05c19 100644
--- a/src/command.c
+++ b/src/command.c
@@ -2870,14 +2870,17 @@ read_line(const char *prompt, int start)
TBOOLEAN more = FALSE;
int last = 0;
+ fprintf(stderr,"AMD::command.c::read_line: Entering function\n");
current_prompt = prompt; /* HBB NEW 20040727 */
do {
/* grab some input */
+ fprintf(stderr,"AMD::command.c::read_line: flag 1\n");
if (gp_get_string(gp_input_line + start, gp_input_line_len - start,
((more) ? ">" : prompt))
== (char *) NULL)
{
+ fprintf(stderr,"AMD::command.c::read_line: flag 2a\n");
/* end-of-file */
if (interactive)
(void) putc('\n', stderr);
@@ -2888,6 +2891,7 @@ read_line(const char *prompt, int start)
else
return (1); /* exit gnuplot */
} else {
+ fprintf(stderr,"AMD::command.c::read_line: flag 2b\n");
/* normal line input */
/* gp_input_line must be NUL-terminated for strlen not to pass the
* the bounds of this array */