From 55597ac608dc638a235423f8a37848b3f829c30f Mon Sep 17 00:00:00 2001 From: martin-s Date: Mon, 19 May 2008 17:49:40 +0000 Subject: [PATCH] Fix:Core:Don't crash when wordexp returns an error git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1064 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/navit/navit/file.c b/navit/navit/file.c index 9fadf45..db157d7 100644 --- a/navit/navit/file.c +++ b/navit/navit/file.c @@ -275,14 +275,18 @@ file_destroy(struct file *f) } struct file_wordexp { + int err; wordexp_t we; }; struct file_wordexp * file_wordexp_new(const char *pattern) { - struct file_wordexp *ret=g_new(struct file_wordexp, 1); - wordexp(pattern, &ret->we, 0); + struct file_wordexp *ret=g_new0(struct file_wordexp, 1); + + ret->err=wordexp(pattern, &ret->we, 0); + if (ret->err) + dbg(0,"wordexp('%s') returned %d\n", pattern, ret->err); return ret; } @@ -301,7 +305,8 @@ file_wordexp_get_array(struct file_wordexp *wexp) void file_wordexp_destroy(struct file_wordexp *wexp) { - wordfree(&wexp->we); + if (! wexp->err) + wordfree(&wexp->we); g_free(wexp); } -- 2.7.4