diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Hooks/abrt-pyhook-helper.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Hooks/abrt-pyhook-helper.cpp b/src/Hooks/abrt-pyhook-helper.cpp index 7ad605f..f8bda84 100644 --- a/src/Hooks/abrt-pyhook-helper.cpp +++ b/src/Hooks/abrt-pyhook-helper.cpp @@ -98,20 +98,26 @@ int main(int argc, char** argv) char *bt = (char*)malloc(capacity); if (!bt) { - printf("Error while allocating memory for backtrace.\n"); + fprintf(stderr, "Error while allocating memory for backtrace.\n"); return 1; } char *btptr = bt; while ((c = getchar()) != EOF) { - *btptr++ = (char)c; + *btptr++ = (char)c; if (btptr - bt >= capacity - 1) { capacity *= 2; + if (capacity > 1048576) // > 1 MB + { + fprintf(stderr, "Backtrace size limit exceeded. Trimming to 1 MB.\n"); + break; + } + bt = (char*)realloc(bt, capacity); if (!bt) { - printf("Error while allocating memory for backtrace.\n"); + fprintf(stderr, "Error while allocating memory for backtrace.\n"); return 1; } } |
