From 5917f3b3fefcc24afd9b75d2c502552ff841d09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 12 May 2012 23:49:07 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Fix a crash in the &/ operator. git-svn-id: svn://localhost/gambas/trunk@4725 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_subr_string.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/main/gbx/gbx_subr_string.c b/main/gbx/gbx_subr_string.c index e8f91ad37..64106daa0 100644 --- a/main/gbx/gbx_subr_string.c +++ b/main/gbx/gbx_subr_string.c @@ -149,25 +149,29 @@ void SUBR_file(ushort code) i = NPARAM; while (i--) { - VALUE_get_string(PARAM, &addr, &len); - - if (len > 0) + if (PARAM->type != T_NULL) { - if (ptr > str) + VALUE_get_string(PARAM, &addr, &len); + + if (len > 0) { - if (!slash && *addr != '/') - *ptr++ = '/'; - else if (slash && *addr == '/') - ptr--; + if (ptr > str) + { + if (!slash && *addr != '/') + *ptr++ = '/'; + else if (slash && *addr == '/') + ptr--; + } + + slash = addr[len - 1] == '/'; + + memcpy(ptr, addr, len); + ptr += len; } - - slash = addr[len - 1] == '/'; - - memcpy(ptr, addr, len); - ptr += len; - } - RELEASE_STRING(PARAM); + RELEASE_STRING(PARAM); + } + PARAM++; }