aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2017-04-04 21:40:59 +0200
committerJ08nY2017-04-04 21:40:59 +0200
commitb77fd8c4eb3f1dba399d8451909fefc52b436c35 (patch)
treeb2286fa00d61826667b77f58f059cbac1434d2ff
parent797c95c15c6c8f2e312fa402f5eb63b41697a406 (diff)
downloadecgen-b77fd8c4eb3f1dba399d8451909fefc52b436c35.tar.gz
ecgen-b77fd8c4eb3f1dba399d8451909fefc52b436c35.tar.zst
ecgen-b77fd8c4eb3f1dba399d8451909fefc52b436c35.zip
Fix input
-rw-r--r--src/io/input.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/io/input.c b/src/io/input.c
index 9519671..4697d05 100644
--- a/src/io/input.c
+++ b/src/io/input.c
@@ -26,6 +26,17 @@ GEN input_i(const char *prompt, long bits) {
;
pari_sp ltop = avma;
+ if (len <= 3 || line[0] != '0' && (line[1] != 'x' || line[1] != 'X')) {
+ char *new_line = realloc(line, (size_t)(len + 2));
+ if (!new_line) {
+ perror("Couldn't alloc.");
+ exit(1);
+ }
+ memmove(new_line + 2, new_line, (size_t)len);
+ new_line[0] = '0';
+ new_line[1] = 'x';
+ line = new_line;
+ }
GEN in = strtoi(line);
free(line);