Skip to content

Commit

Permalink
Fix segfault with array tos
Browse files Browse the repository at this point in the history
  • Loading branch information
refi64 committed Nov 6, 2015
1 parent c2771fb commit 43dd9bd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions o2.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ S tos(O o){
S r;switch(o->t){
case TD:r=alc(BZ)/*hope this is big enough!*/;if(o->d==(I)o->d)sprintf(r,"%d",(I)o->d);else sprintf(r,"%f",o->d);BK;
case TS:case TCB:r=alc(o->s.z+1);memcpy(r,o->s.s,o->s.z);r[o->s.z]=0;BK;
case TA:strcat(r,"[");I l=len(o->a);if(l){I i;for(i=0;i<l;++i){
if(i) strcat(r,",");strcat(r,tos(o->a->st[i]));
case TA:r=alc(BZ)/*XXX:overflow potential here!again!*/;r[0]='[';r[1]=0;I l=len(o->a);if(l){I i;for(i=0;i<l;++i){
if(i)strcat(r,",");strcat(r,tos(o->a->st[i]));
}}strcat(r,"]");BK;
}R r;
} //tostring (copies)
Expand Down

0 comments on commit 43dd9bd

Please sign in to comment.