Skip to content

Commit bc382f1

Browse files
author
t68
committed
Two bugs: one with simple dollar argument and one with very short input.
1 parent 7439170 commit bc382f1

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

sources/pre.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ int ExpandTripleDots(int par)
13721372
}
13731373
s = Buffer; while ( *s ) s++;
13741374
fullsize = s - Buffer;
1375+
if ( fullsize < 7 ) return(error);
13751376

13761377
s = Buffer+2;
13771378
while ( *s ) {
@@ -1690,7 +1691,7 @@ theend: M_free(nums,"Expand ...");
16901691
}
16911692

16921693
/*
1693-
#] ExpandTripleDots :
1694+
#] ExpandTripleDots :
16941695
#[ FindKeyWord :
16951696
*/
16961697

sources/ratio.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,18 +2237,24 @@ divzero:;
22372237
}
22382238
if ( ( proper1 = PutExtraSymbols(BHEAD arg1,startebuf,&actionflag1) ) == 0 ) goto CalledFrom;
22392239
if ( ( proper2 = PutExtraSymbols(BHEAD arg2,startebuf,&actionflag2) ) == 0 ) goto CalledFrom;
2240+
/*
22402241
if ( type2 == 0 ) M_free(arg2,"DIVfunction");
22412242
else {
22422243
DOLLARS d = ((DOLLARS)arg2)-1;
22432244
if ( d->factors ) M_free(d->factors,"Dollar factors");
22442245
M_free(d,"Copy of dollar variable");
22452246
}
2247+
*/
2248+
M_free(arg2,"DIVfunction");
2249+
/*
22462250
if ( type1 == 0 ) M_free(arg1,"DIVfunction");
22472251
else {
22482252
DOLLARS d = ((DOLLARS)arg1)-1;
22492253
if ( d->factors ) M_free(d->factors,"Dollar factors");
22502254
M_free(d,"Copy of dollar variable");
22512255
}
2256+
*/
2257+
M_free(arg1,"DIVfunction");
22522258
if ( par == 0 ) proper3 = poly_div(BHEAD proper1, proper2);
22532259
else if ( par == 1 ) proper3 = poly_rem(BHEAD proper1, proper2);
22542260
else if ( par == 2 ) proper3 = poly_inverse(BHEAD proper1, proper2);
@@ -2300,7 +2306,7 @@ divzero:;
23002306
}
23012307

23022308
/*
2303-
#] DIVfunction :
2309+
#] DIVfunction :
23042310
#[ ConvertArgument :
23052311
23062312
Converts an argument to a general notation in allocated space.
@@ -2332,7 +2338,7 @@ WORD *ConvertArgument(PHEAD WORD *arg, int *type)
23322338
*/
23332339
output = (WORD *)Malloc1((d->size+1)*sizeof(WORD),"Copy of dollar content");
23342340
WCOPY(output,d->where,d->size+1);
2335-
if ( d->factors ) M_free(d->factors,"Dollar factors");
2341+
if ( d->factors ) { M_free(d->factors,"Dollar factors"); d->factors = 0; }
23362342
M_free(d,"Copy of dollar variable");
23372343
return(output);
23382344
}

0 commit comments

Comments
 (0)