From: nishi Date: Thu, 23 May 2024 03:39:13 +0000 (+0000) Subject: fix stuff X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=8f1f4f327c5dc23019b9f65003df53236f157bd2;p=dataworks.git fix stuff git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@85 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/main.c b/Client/main.c index f0b2704..42bc13d 100644 --- a/Client/main.c +++ b/Client/main.c @@ -237,11 +237,13 @@ int main(int argc, char** argv) { printf("%s\n", line); } free(line); - char* newbuf = malloc(strlen(linebuf) - i); - newbuf[strlen(linebuf) - i - 1] = 0; - memcpy(newbuf, linebuf + i + 1, strlen(linebuf) - i - 1); - free(linebuf); - linebuf = newbuf; + if(strlen(linebuf) > 0){ + char* newbuf = malloc(strlen(linebuf) - i); + newbuf[strlen(linebuf) - i - 1] = 0; + memcpy(newbuf, linebuf + i + 1, strlen(linebuf) - i - 1); + free(linebuf); + linebuf = newbuf; + } continue; } } diff --git a/Library/parser.c b/Library/parser.c index 6ef9929..5a31c15 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -61,6 +61,12 @@ struct __dw_token* __dw_parser_parse(const char* name, const char* str) { } else { printf("%s:%s\n", buf, br); __dw_parser_parse(buf, br); + free(br); + br = malloc(1); + br[0] = 0; + free(buf); + buf = malloc(1); + buf[0] = 0; } } else if(dq) { char* tmp = buf; diff --git a/common-decl.mk b/common-decl.mk index bd35c34..012e12d 100644 --- a/common-decl.mk +++ b/common-decl.mk @@ -5,7 +5,7 @@ SHCC = cc AR = ar AR_ARGS = rcs \$$@ RANLIB = ranlib -CFLAGS = -std=c99 -D_DEFAULT_SOURCE +CFLAGS = -g -std=c99 -D_DEFAULT_SOURCE LDFLAGS = -L`pwd`/Library LIBS = LIB_PREFIX = lib