[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] s_recvoscmsg bug causes crashes - heureka - [commit?]



Problem: osc responder crashes sclang on recieving a string larger than 255.

Reason: This is due to the fact that an incoming string is converted into a Symbol by sclang. When creating a symbol from a string, the string normally is truncated to 255 characters. Seemingly the attempt to create a symbol larger than this causes the sclang to crash.


// the problem is in PyrObject* ConvertOSCMessage(int inSize, char *inData):

case 's' :
                    SetSymbol(slots+i+1, getsym(msg.gets()));
                    //post("sym '%s'\n", slots[i+1].us->name);
                    break;

// I have fixed it as follows:

		inchars = msg.gets();
		size = strlen(inchars);


		if(size < 256) {
			SetSymbol(slots+i+1, getsym(inchars));
					} else {
PyrString *strobj = newPyrStringN(g->gc, size, 0, true);
			memcpy(strobj->s, inchars, size);
			SetObject(slots+i+1, strobj);
		}


// ok to commit ?



Maybe there should be a lower limit than 255. I think normally Strings that are really meant to be Symbols are usually not logner than, say 32 characters.
As it is, it contraminates the Symbol lookup table which gets slower then, too.

so should it be

if(size < 33) { ?

I would then document this in OSCresponder helpfile.
--








.