From 7e027ada712b749b2c64f36db26b83a1bcd1c763 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 30 Apr 2005 17:16:17 +0000 Subject: [PATCH] null-pointer problem wenn SHORT_STRINGS aktiv --- src/common/kernel/order.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/common/kernel/order.c b/src/common/kernel/order.c index 71ae03442..7ad145359 100644 --- a/src/common/kernel/order.c +++ b/src/common/kernel/order.c @@ -30,7 +30,8 @@ void copy_order(order * dst, const order * src) { if (dst->_str) free(dst->_str); - dst->_str = strdup(src->_str); + if (src->_str) dst->_str = strdup(src->_str); + else dst->_str = NULL; dst->_keyword = src->_keyword; dst->_lindex = src->_lindex; dst->_persistent = src->_persistent; @@ -65,18 +66,18 @@ getcommand(const order * ord) } } #endif - strcpy(str, ord->_str); + if (ord->_str) strcpy(str, ord->_str); return strdup(sbuffer); } void free_order(order * ord) { - if (ord!=NULL && --ord->_refcount==0) { + if (ord!=NULL && --ord->_refcount==0) { assert(ord->next==NULL); - if (ord->_str!=NULL) free(ord->_str); - free(ord); - } + if (ord->_str!=NULL) free(ord->_str); + free(ord); + } } order *