Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4849813pxv; Tue, 27 Jul 2021 18:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyznn5iy2w/EYGuf8aEgvOV5QH7HPOI3ycpwJJns77fMLB2eSlhN3zEl/P6fIRKh22kkXZc X-Received: by 2002:a5d:9808:: with SMTP id a8mr15848304iol.1.1627437491160; Tue, 27 Jul 2021 18:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627437491; cv=none; d=google.com; s=arc-20160816; b=TagwKft+bIYX+/v1TVyIoLEuux/SLP6teH2ihzepZjZvKPBis9F8lJq0EFmSO2yeTS pD+i4eWIRKwOZDY3GZ3HQgJMML0sSL8IRYo27yuxKf/dLArn3048UHUju/ST2iYC2LR7 ggeMkt6rZYVzNCfSKjSeKTNlfbte59ed2vETjSIWuXHVMyigJkyyBXBPINUFzWrcQT9f u+eKad2zIxENyNDXi1blQsk9waSyRyx0Z/BhUBD7YfRxppVleBVcrg9Qe8YVPSmQ1pPU I/Cmd2Abwx013jsB4hjDa09nqbhzvf+gQvTK328H4HvTIQIIo4J6Cd/9rYxZcY0dxklu WzMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pMPZTbpiGMoIXHwPpgc+5Aash5m8TywyUUppJ9+xffE=; b=FhLCe8Z5RXx+EB12m0tWZrd69IODMhyRCGP174i3kBfYuI6MoMMQ52qxvOteGsCd/k VUwHa2Jd2uupF59tR8pPLRIlcrAD0vjtsnqToqBV40CuZ+8ioK6xodkKpQIu3IXO/wWT DOEkRnI8lUnemYp8M4BlLkMdONOKkNVzgHzHnSuYZM2fVWiub80OJIRXD3u4RYwnk6hd 1rTSBwfPZY11RdLZkTtzQsMiIvtCHicMJhi+Lkzh1mJnIc+JUJ9ifOM40XLQI1gWHGiD xt7/jtRWabfCjFsVeqZ9iVbZdCGUZl3+1sw/jwuWKmU6pF6sY+GZHgT1HSjuVVtPaxjm t+CQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si5011314ior.73.2021.07.27.18.57.59; Tue, 27 Jul 2021 18:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234133AbhG1B4g (ORCPT + 99 others); Tue, 27 Jul 2021 21:56:36 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:12273 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233865AbhG1B4f (ORCPT ); Tue, 27 Jul 2021 21:56:35 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4GZGp562Nrz1CPbH; Wed, 28 Jul 2021 09:50:37 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 28 Jul 2021 09:56:24 +0800 Received: from huawei.com (10.175.104.170) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 28 Jul 2021 09:56:23 +0800 From: wuguanghao To: , CC: , , Subject: [PATCH v3 04/12] ss_add_info_dir: don't zap the info->info_dirs and check whether Date: Wed, 28 Jul 2021 09:56:45 +0800 Message-ID: <20210728015648.284588-2-wuguanghao3@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210728015648.284588-1-wuguanghao3@huawei.com> References: <20210728015648.284588-1-wuguanghao3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Wu Guanghao In ss_add_info_dir(), don't zap the info->info_dirs. At the same time, it is necessary to check whether dirs[n_dirs] is a null pointer, otherwise a segmentation fault will occur. Signed-off-by: Wu Guanghao Signed-off-by: Zhiqiang Liu Reviewed-by: Wu Bo --- lib/ss/help.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ss/help.c b/lib/ss/help.c index 5204401b..b4465bfe 100644 --- a/lib/ss/help.c +++ b/lib/ss/help.c @@ -148,13 +148,16 @@ void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr) dirs = (char **)realloc((char *)dirs, (unsigned)(n_dirs + 2)*sizeof(char *)); if (dirs == (char **)NULL) { - info->info_dirs = (char **)NULL; *code_ptr = errno; return; } info->info_dirs = dirs; dirs[n_dirs + 1] = (char *)NULL; dirs[n_dirs] = malloc((unsigned)strlen(info_dir)+1); + if (dirs[n_dirs] == (char *)NULL) { + *code_ptr = errno; + return; + } strcpy(dirs[n_dirs], info_dir); *code_ptr = 0; } -- 2.27.0