From: Manjeet Pawar <manjee...@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.g...@samsung.com>
Signed-off-by: Manjeet Pawar <manjee...@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 via email to