: Add check for realloc() failure case
PATCH 1/1 : Add check for realloc() failure case
From: Manjeet Pawar <[email protected]>
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 <[email protected]>
Signed-off-by Manjeet Pawar <[email protected]>
--- testcases/network/nfs/nfs_fsstress/fsstress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/network/nfs/nfs_fsstress/fsstress.c +6 -2
@@ -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);
Signature · 7 lines
1.7.9.5 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list