public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Manjeet Pawar <manjeet.p@samsung.com>
To: "ltp-list@lists.sourceforge.net" <ltp-list@lists.sourceforge.net>
Cc: "ajeet.y@samsung.com" <ajeet.y@samsung.com>,
	Yogesh Narayan Gaur <yn.gaur@samsung.com>
Subject: [LTP]  [PATCH]: Add check for realloc() failure case
Date: Thu, 28 May 2015 04:36:27 +0000 (GMT)	[thread overview]
Message-ID: <1124984645.189951432787787528.JavaMail.weblogic@epmlwas05c> (raw)

From: Manjeet Pawar <manjeet.p@samsung.com>
Subject: [PATCH] testcases/network/nfs/nfs_fsstress/fsstress.c: Add check for realloc() failure case 

This patch add check for realloc failure case and exit from the testcase if realloc fails.

Signed-off-by: Yogesh Gaur <yn.gaur@samsung.com>
Signed-off-by: Manjeet Pawar <manjeet.p@samsung.com>
---
 testcases/network/nfs/nfs_fsstress/fsstress.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/testcases/network/nfs/nfs_fsstress/fsstress.c b/testcases/network/nfs/nfs_fsstress/fsstress.c
index ac91262..208c2dc 100644
--- a/testcases/network/nfs/nfs_fsstress/fsstress.c
+++ b/testcases/network/nfs/nfs_fsstress/fsstress.c
@@ -330,8 +330,12 @@ int main(int argc, char **argv)
 			process_freq(optarg);
 			break;
 		case 'i':
-			ilist = realloc(ilist, ++ilistlen * sizeof(*ilist));
-			ilist[ilistlen - 1] = strtol(optarg, &p, 16);
+			if(realloc(ilist, ++ilistlen * sizeof(*ilist)) != NULL)
+				ilist[ilistlen - 1] = strtol(optarg, &p, 16);
+			else{
+				fprintf(stderr, "realloc: New memory allocation failed \n");
+				exit(1);
+			}
 			break;
 		case 'l':
 			loops = atoi(optarg);
-- 
1.7.9.5

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

             reply	other threads:[~2015-05-28  4:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28  4:36 Manjeet Pawar [this message]
     [not found] <149090115.398111433218346536.JavaMail.weblogic@epmlwas08b>
2015-06-04 16:27 ` [LTP] [PATCH]: Add check for realloc failure case Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2015-05-28  4:33 [LTP] [PATCH]: Add check for realloc() " Manjeet Pawar
2015-06-01 14:25 ` Cyril Hrubis
2015-05-28  4:30 [LTP] [PATCH]: Add check for realloc " Manjeet Pawar
2015-06-01 14:22 ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1124984645.189951432787787528.JavaMail.weblogic@epmlwas05c \
    --to=manjeet.p@samsung.com \
    --cc=ajeet.y@samsung.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=yn.gaur@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox