Skip to content

Commit a3fa35b

Browse files
committed
COMMON: INPUT crash #99
1 parent 903cad3 commit a3fa35b

File tree

9 files changed

+20
-17
lines changed

9 files changed

+20
-17
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2020-05-04 (0.12.19)
2+
INPUT crash #99
3+
Fix compile warning with updated gcc
4+
15
2020-03-07 (0.12.19)
26
COMMON: implement DEFINEKEY undo #92
37
UI: added R157 colour theme #94

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ function checkDebugMode() {
7474
AC_MSG_RESULT([$with_debug])
7575
if test "$with_debug" = "yes" || test "$with_debug" = "full"
7676
then
77-
CFLAGS="${CFLAGS} -g -O0"
78-
CXXFLAGS="${CXXFLAGS} -g -O0"
77+
CFLAGS="${CFLAGS} -g -O0 -fstack-protector-all"
78+
CXXFLAGS="${CXXFLAGS} -g -O0 -fstack-protector-all"
7979
AC_DEFINE(_DEBUG, 1, [debugging build enabled])
8080
fi
8181
AC_SUBST(CFLAGS)

samples/distro-examples/tests/keymap.bas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ if (instr(sbver, "SDL") <> 0) then
3232
wend
3333
endif
3434

35+
print "done"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.11111111111111E+74
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
done

src/common/blib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ void cmd_input(int input) {
751751
inps = malloc(SB_TEXTLINE_SIZE + 1);
752752
if (prompt.v.p.ptr) {
753753
// prime output buffer with prompt text
754-
int prompt_len = strlen(prompt.v.p.ptr);
754+
int prompt_len = v_strlen(&prompt);
755755
int len = prompt_len < SB_TEXTLINE_SIZE ? prompt_len : SB_TEXTLINE_SIZE;
756756
strncpy(inps, prompt.v.p.ptr, len);
757757
inps[len] = 0;

src/common/units.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,15 @@ int close_unit(int uid) {
218218
* @return 0 on success
219219
*/
220220
int import_unit(int uid) {
221-
char buf[SB_KEYWORD_SIZE + 1];int i;
222-
223221
if (uid >= 0) {
224222
unit_t *u = &units[uid];
225223
if (u->status == unit_loaded) {
226-
for (i = 0; i < u->hdr.sym_count; i++) {
227-
// build the name
228-
// with any path component removed from the name
224+
for (int i = 0; i < u->hdr.sym_count; i++) {
225+
// build the name with any path component removed from the name
226+
char buf[SB_KEYWORD_SIZE + SB_KEYWORD_SIZE + 1];
229227
char *dir_sep = strrchr(u->hdr.base, OS_DIRSEP);
230228
sprintf(buf, "%s.%s",
231-
dir_sep ? dir_sep + 1 : u->hdr.base, u->symbols[i].symbol);
232-
229+
dir_sep ? dir_sep + 1 : u->hdr.base, u->symbols[i].symbol);
233230
switch (u->symbols[i].type) {
234231
case stt_function:
235232
comp_add_external_func(buf, uid | UID_UNIT_BIT);
@@ -242,12 +239,10 @@ int import_unit(int uid) {
242239
break;
243240
};
244241
}
245-
}
246-
else {
242+
} else {
247243
return -2;
248244
}
249-
}
250-
else {
245+
} else {
251246
return -1;
252247
}
253248

src/common/var.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,15 +767,15 @@ void v_zerostr(var_t *r) {
767767
void v_input2var(const char *str, var_t *var) {
768768
v_free(var);
769769

770-
if (strlen(str) == 0) {
770+
if (!str || str[0] == '\0') {
771771
// no data
772772
v_setstr(var, str);
773773
} else {
774-
char buf[INT_STR_LEN];
775774
int type;
776775
var_int_t lv;
777776
var_num_t dv;
778777

778+
char *buf = strdup(str);
779779
char *sb = strdup(str);
780780
char *np = get_numexpr(sb, buf, &type, &lv, &dv);
781781

@@ -787,6 +787,7 @@ void v_input2var(const char *str, var_t *var) {
787787
v_setstr(var, str);
788788
}
789789
free(sb);
790+
free(buf);
790791
}
791792
}
792793

src/platform/console/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sbasic_DEPENDENCIES = $(top_srcdir)/src/common/libsb_common.a
2727
TEST_DIR=../../../samples/distro-examples/tests
2828
UNIT_TESTS=array break byref eval-test iifs matrices metaa ongoto \
2929
uds hash pass1 call_tau short-circuit strings stack-test \
30-
replace-test read-data proc optchk letbug ptr ref \
30+
replace-test read-data proc optchk letbug ptr ref input \
3131
trycatch chain stream-files split-join sprint all scope goto keymap
3232

3333
test: ${bin_PROGRAMS}

0 commit comments

Comments
 (0)