Message ID | 20210630082724.50838-13-wuguanghao3@huawei.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2,01/12] profile_create_node: set magic before strdup(name) to avoid memory leak | expand |
On Wed, Jun 30, 2021 at 04:27:24PM +0800, wuguanghao wrote: > From: Zhiqiang Liu <liuzhiqiang26@huawei.com> > > In dupstr(), we should check return value of malloc(). Thanks, applied. - Ted
diff --git a/ext2ed/main.c b/ext2ed/main.c index f7e7d7df..9d33a8e1 100644 --- a/ext2ed/main.c +++ b/ext2ed/main.c @@ -524,6 +524,8 @@ char *dupstr (char *src) char *ptr; ptr=(char *) malloc (strlen (src)+1); + if (!ptr) + return NULL; strcpy (ptr,src); return (ptr); }