diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-07-06 15:51:38 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-07-06 15:51:38 +0000 |
commit | 7eb23e0811b14d0b8f5c08c87ab4b5d1ef913581 (patch) | |
tree | 42bdc69101b381a1ff7b380846d30080e65eafd3 /gdb/findcmd.c | |
parent | d479bbcb47a1dacba22919cfdb47db696e95f932 (diff) | |
download | gdb-7eb23e0811b14d0b8f5c08c87ab4b5d1ef913581.tar.gz |
gdb/
PR 14321
* findcmd.c (parse_find_args): New variable pattern_buf_size_need.
Increase buffer sizes to 2x we need, not just 2x of the previous size.
gdb/testsuite/
PR 14321
* gdb.base/find.exp
(find int64_search_buf, +64/8*100, int64_search_buf): New test.
Diffstat (limited to 'gdb/findcmd.c')
-rw-r--r-- | gdb/findcmd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/findcmd.c b/gdb/findcmd.c index 3fce2695919..68184aa27e9 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -170,6 +170,7 @@ parse_find_args (char *args, ULONGEST *max_countp, { LONGEST x; int val_bytes; + ULONGEST pattern_buf_size_need; while (isspace (*s)) ++s; @@ -179,12 +180,13 @@ parse_find_args (char *args, ULONGEST *max_countp, /* Keep it simple and assume size == 'g' when watching for when we need to grow the pattern buf. */ - if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t))) - > pattern_buf_size) + pattern_buf_size_need = (pattern_buf_end - pattern_buf + + max (val_bytes, sizeof (int64_t))); + if (pattern_buf_size_need > pattern_buf_size) { size_t current_offset = pattern_buf_end - pattern_buf; - pattern_buf_size *= 2; + pattern_buf_size = pattern_buf_size_need * 2; pattern_buf = xrealloc (pattern_buf, pattern_buf_size); pattern_buf_end = pattern_buf + current_offset; } |