summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-02-12 22:00:18 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2010-02-12 22:00:18 +0300
commitbebf0d2157951250d91390fceac8a51fbc08c3a1 (patch)
tree8dc5e6bda41ac36778d56e085c3663c5348f4ade
parentd5d36498aa24e9698d88e902416384d5f1c4d319 (diff)
downloadnasm-bebf0d2157951250d91390fceac8a51fbc08c3a1.tar.gz
preproc.c: Fix NULL dereference on package absence
If package can't be retrieved we should not attempt to dereference NULL'ed pointer which leads to segmentation fault. Reported-by: Serge Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--preproc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/preproc.c b/preproc.c
index 5d97b2a2..fcec93d6 100644
--- a/preproc.c
+++ b/preproc.c
@@ -2398,7 +2398,7 @@ static int do_directive(Token * tline)
case PP_USE:
{
static macros_t *use_pkg;
- const char *pkg_macro;
+ const char *pkg_macro = NULL;
tline = tline->next;
skip_white_(tline);
@@ -2419,9 +2419,9 @@ static int do_directive(Token * tline)
use_pkg = nasm_stdmac_find_package(tline->text);
if (!use_pkg)
error(ERR_NONFATAL, "unknown `%%use' package: %s", tline->text);
- /* The first string will be <%define>__USE_*__ */
- pkg_macro = (char *)use_pkg + 1;
- if (!smacro_defined(NULL, pkg_macro, 0, NULL, true)) {
+ else
+ pkg_macro = (char *)use_pkg + 1; /* The first string will be <%define>__USE_*__ */
+ if (use_pkg && smacro_defined(NULL, pkg_macro, 0, NULL, true)) {
/* Not already included, go ahead and include it */
stdmacpos = use_pkg;
}