[pacman-dev,v4,2/2] pacman-conf.c: exit if cannot create config data structure

Message ID 20180215222040.16984-2-iff@escondida.tk
State Accepted, archived
Headers show
Series [pacman-dev,v4,1/2] pacman-conf.c: add short options | expand

Commit Message

Ivy Foster Feb. 15, 2018, 10:20 p.m. UTC
From: Ivy Foster <iff@escondida.tk>

---
 src/pacman/pacman-conf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andrew Gregory Feb. 16, 2018, 3:58 a.m. UTC | #1
On 02/15/18 at 04:20pm, iff@escondida.tk wrote:
> From: Ivy Foster <iff@escondida.tk>
> 
> ---
>  src/pacman/pacman-conf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index ab73d896..4ffa24a3 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -400,7 +400,10 @@ int main(int argc, char **argv)
>  {
>  	int ret = 0;
>  
> -	config = config_new();
> +	if(!(config = config_new())) {
> +		/* config_new prints the appropriate error message */
> +		return 1;
> +	}
>  	parse_opts(argc, argv);
>  	if(!config) {
>  		ret = 1;

ACK.

Patch

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index ab73d896..4ffa24a3 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -400,7 +400,10 @@  int main(int argc, char **argv)
 {
 	int ret = 0;
 
-	config = config_new();
+	if(!(config = config_new())) {
+		/* config_new prints the appropriate error message */
+		return 1;
+	}
 	parse_opts(argc, argv);
 	if(!config) {
 		ret = 1;