From 287bbfeea3a4fcaca0b0c5345d8159a6b484856b Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 10 Feb 2011 14:29:29 +0000 Subject: [PATCH] pn53x-tamashell: fix bug introduced by r878 --- examples/pn53x-tamashell.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index a9dbb61..3d76fe8 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -101,18 +101,17 @@ int main(int argc, const char* argv[]) add_history(cmd); } else { #endif //HAVE_READLINE - cmd = NULL; + size_t n = 255; + char * ret = NULL; + cmd = malloc(n); printf("%s", prompt); fflush(0); - size_t n; - int s; if (input != NULL) { - fgets(cmd, n, input); + ret = fgets(cmd, n, input); } else { - fgets(cmd, n, stdin); + ret = fgets(cmd, n, stdin); } - s = strlen(cmd); - if (s <= 0) { + if (ret == NULL || strlen(cmd) <= 0) { printf("Bye!\n"); free(cmd); break;