Explorar o código

fixed mismatch in bytes vs chars

Nicolas Cannasse %!s(int64=7) %!d(string=hai) anos
pai
achega
53d1dd6c6c
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 2 2
      src/std/error.c
  2. 1 1
      src/std/ucs2.c

+ 2 - 2
src/std/error.c

@@ -140,7 +140,7 @@ HL_PRIM vdynamic *hl_alloc_strbytes( const uchar *fmt, ... ) {
 	vdynamic *d;
 	int len;
 	uchar *buf = _buf;
-	int bsize = sizeof(_buf);
+	int bsize = sizeof(_buf) / sizeof(uchar);
 	va_list args;
 	while( true ) {
 		va_start(args, fmt);
@@ -149,7 +149,7 @@ HL_PRIM vdynamic *hl_alloc_strbytes( const uchar *fmt, ... ) {
 		if( (len + 2) << 1 < bsize ) break;
 		if( buf != _buf ) free(buf);
 		bsize <<= 1;
-		buf = (uchar*)malloc(bsize);
+		buf = (uchar*)malloc(bsize * sizeof(uchar));
 	}
 	d = hl_alloc_dynamic(&hlt_bytes);
 	d->v.ptr = hl_copy_bytes((vbyte*)buf,(len + 1) << 1);

+ 1 - 1
src/std/ucs2.c

@@ -169,7 +169,7 @@ void uprintf( const uchar *fmt, const uchar *str ) {
 
 HL_PRIM int uvszprintf( uchar *out, int out_size, const uchar *fmt, va_list arglist ) {
 	uchar *start = out;
-	uchar *end = out + (out_size >> 1) - 1;
+	uchar *end = out + out_size - 1;
 	char cfmt[20];
 	char tmp[32];
 	uchar c;