From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=bkcPH1h4; spf=pass (domain: gmx.de, ip: 212.227.17.22, mailfrom: xypron.glpk@gmx.de) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by groups.io with SMTP; Tue, 09 Apr 2019 12:37:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1554838662; bh=NAhOvq9yRFOazU5qE8MCF4q4MFA1gPkfjvPCRBKvHUM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=bkcPH1h42vrcihb4rC7AoYuk19vCHG7f38dXte80hZuSbja5hZp0N3NfjD3fp7HKu BjFd/aNc7FNMfbSBzmCqNCe2UnJvONRCqrsSKlmkEO9XDUQ+ZdQen6i5GVCXWnms5d sx2FPDKNhr8sLBihTU1AruXi42Rdyrb0S7PS4Rj0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([84.118.159.3]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MF9WR-1h885N2rMZ-00GI1E; Tue, 09 Apr 2019 21:37:42 +0200 From: "Heinrich Schuchardt" To: Jaben Carsey , Ray Ni , Leif Lindholm , Ard Biesheuvel Cc: Ruiyu Ni , devel@edk2.groups.io, Heinrich Schuchardt Subject: [PATCH v2 1/1] ShellPkg/CommandLib: avoid NULL derefence and memory leak Date: Tue, 9 Apr 2019 21:37:38 +0200 Message-Id: <20190409193738.10521-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:4e3orWw7drjaPmhiofYwTeWRH53PZYOwA/YE3rIlucHLD6KCa14 BJn8hygLOu5G2fqY5F3ktU1u035xlavHKRNtKbEXi+jNx4u1c1kjbSTN1jRztRCVtGHxAku wOelZTICBFzt74cRCQiQYp9rUsZK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BnQlMtPkxvY2F0ZUhhbmRsZUJ1ZmZl ciAoDQogICAgICAgICAgICAgICAgICAgICBCeVByb3RvY29sLA0KICAgICAgICAgICAgICAgICAg ICAgJmdFZmlVbmljb2RlQ29sbGF0aW9uMlByb3RvY29sR3VpZCwNCkBAIC0xMTMsNiArMTExLDE0 IEBAIENvbW1hbmRJbml0KAogICAgICAgICBjb250aW51ZTsNCiAgICAgICB9DQogDQorICAgICAg Ly8NCisgICAgICAvLyBXaXRob3V0IGNsdWUgcHJvdmlkZWQgdXNlIHRoZSBmaXJzdCBVbmljb2Rl IENvbGxhdGlvbjIgcHJvdG9jb2wuDQorICAgICAgLy8NCisgICAgICBpZiAoUGxhdGZvcm1MYW5n ID09IE5VTEwpIHsNCisgICAgICAgIGdVbmljb2RlQ29sbGF0aW9uID0gVWM7DQorICAgICAgICBi cmVhazsNCisgICAgICB9DQorDQogICAgICAgLy8NCiAgICAgICAvLyBGaW5kIHRoZSBiZXN0IG1h dGNoaW5nIG1hdGNoaW5nIGxhbmd1YWdlIGZyb20gdGhlIHN1cHBvcnRlZCBsYW5ndWFnZXMNCiAg ICAgICAvLyBvZiBVbmljb2RlIENvbGxhdGlvbjIgcHJvdG9jb2wuDQpAQCAtMTMyLDcgKzEzOCw5 IEBAIENvbW1hbmRJbml0KAogICAgIGlmIChIYW5kbGVzICE9IE5VTEwpIHsNCiAgICAgICBGcmVl UG9vbCAoSGFuZGxlcyk7DQogICAgIH0NCi0gICAgRnJlZVBvb2wgKFBsYXRmb3JtTGFuZyk7DQor ICAgIGlmIChQbGF0Zm9ybUxhbmcgIT0gTlVMTCkgew0KKyAgICAgIEZyZWVQb29sIChQbGF0Zm9y bUxhbmcpOw0KKyAgICB9DQogICB9DQogDQogICByZXR1cm4gKGdVbmljb2RlQ29sbGF0aW9uID09 IE5VTEwpID8gRUZJX1VOU1VQUE9SVEVEIDogRUZJX1NVQ0NFU1M7DQotLSAKMi4yMC4xCgo=