Revision 18943780 plugins/janus_echotest.c

View differences:

plugins/janus_echotest.c
508 508
			return;
509 509
		if(buf == NULL || len <= 0)
510 510
			return;
511
		char *text = calloc(len+1, sizeof(char));
511
		char *text = g_malloc0(len+1);
512 512
		memcpy(text, buf, len);
513 513
		*(text+len) = '\0';
514 514
		JANUS_LOG(LOG_VERB, "Got a DataChannel message (%zu bytes) to bounce back: %s\n", strlen(text), text);
515
		char reply[1<<16];
516
		memset(reply, 0, 1<<16);
517
		g_snprintf(reply, 1<<16, "Janus EchoTest here! You wrote: %s", text);
518
		free(text);
515
		/* We send back the same text with a custom prefix */
516
		const char *prefix = "Janus EchoTest here! You wrote: ";
517
		char *reply = g_malloc0(strlen(prefix)+len+1);
518
		g_snprintf(reply, strlen(prefix)+len, "%s%s", prefix, text);
519
		g_free(text);
519 520
		gateway->relay_data(handle, reply, strlen(reply));
521
		g_free(reply);
520 522
	}
521 523
}
522 524

  

Also available in: Unified diff