]> gitweb.factorcode.org Git - factor.git/commitdiff
ffi_test.c: Casting a 32bit int to a 64bit pointer is invalid. Instead,
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 5 Jun 2015 17:21:20 +0000 (10:21 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 5 Jun 2015 17:21:20 +0000 (10:21 -0700)
cast it to a 64bit int then to the pointer. Found with visual studio 2015.

vm/ffi_test.c

index e830b50a307356e2247006d3356113e66e35e2a1..5bf0280e00ae29e2af9a0991dc8529ce4c73ae0a 100644 (file)
@@ -334,7 +334,7 @@ struct ulonglong_pair ffi_test_63() {
 }
 
 void* bug1021_test_1(void* x, int y) {
-  return (void*)((y * y) + (long)x);
+  return (void*)(y * y + (size_t)x);
 }
 
 int bug1021_test_2(int x, char *y, void *z) {
@@ -342,5 +342,5 @@ int bug1021_test_2(int x, char *y, void *z) {
 }
 
 void* bug1021_test_3(int x) {
-  return (void*)((long)x);
+  return (void*)(size_t)((long)x);
 }