some fix on strace memory

Yang Zhiguo yzgcsu at cn.fujitsu.com
Thu Dec 13 03:39:57 UTC 2007


Hi:
  I made minor changes on strace on when allocating memory failed.
Could you please review it? Thank you.

--- count.c	2007-12-13 19:28:39.000000000 +0800
+++ count_new.c	2007-12-13 19:20:58.000000000 +0800
@@ -166,6 +166,12 @@ call_summary_pers(FILE *outf)
 	char    error_str[16];
 
 	int    *sorted_count = calloc(sizeof(int), nsyscalls);
+	if (!sorted_count)
+	{
+		fprintf(stderr,
+			"strace: out of memory for call sorted_count\n");
+		exit(1);
+	}
 
 	call_cum = error_cum = tv_cum.tv_sec = tv_cum.tv_usec = 0;
 	if (overhead.tv_sec == -1)

Signed-off-by: "Yang Zhiguo" <yzgcsu at cn.fujitsu.com>

Best Regards






More information about the Strace-devel mailing list