minor changes on strace for memory allocating
Bai Weidong
baiwd at cn.fujitsu.com
Tue Sep 25 01:13:09 UTC 2007
hello:
I am afraid that strace may need minor changes on strace
allocating memory failed. Could you please review patch?
Thank you very much.
Signed-off-by: "Bai Weidong" <baiwd at cn.fujitsu.com>
Best Regards
--- strace-4.5.15/straceold.c 2007-09-24 11:05:43.000000000 +0800
+++ strace-4.5.15/strace.c 2007-09-24 17:18:18.000000000 +0800
@@ -335,7 +335,17 @@ char *argv[];
/* Allocate the initial tcbtab. */
tcbtabsize = argc; /* Surely enough for all -p args. */
tcbtab = (struct tcb **) malloc (tcbtabsize * sizeof tcbtab[0]);
+ if (tcbtab == NULL) {
+ fprintf(stderr, "%s: out of memory\n",
+ progname);
+ exit(1);
+ }
tcbtab[0] = (struct tcb *) calloc (tcbtabsize, sizeof *tcbtab[0]);
+ if (tcbtab[0] == NULL) {
+ fprintf(stderr, "%s: out of memory\n",
+ progname);
+ exit(1);
+ }
for (tcp = tcbtab[0]; tcp < &tcbtab[0][tcbtabsize]; ++tcp)
tcbtab[tcp - tcbtab[0]] = &tcbtab[0][tcp - tcbtab[0]];
More information about the Strace-devel
mailing list