|
1 |
| -void* malloc(unsigned long size); |
| 1 | +using size_t = decltype(sizeof 0); void* malloc(size_t size); |
2 | 2 |
|
3 | 3 | void test1(int size) {
|
4 | 4 | char* p = (char*)malloc(size);
|
@@ -215,7 +215,7 @@ void test13(unsigned len, unsigned index) {
|
215 | 215 |
|
216 | 216 | bool unknown();
|
217 | 217 |
|
218 |
| -void test14(unsigned long n, char *p) { |
| 218 | +void test14(size_t n, char *p) { |
219 | 219 | while (unknown()) {
|
220 | 220 | n++;
|
221 | 221 | p = (char *)malloc(n);
|
@@ -706,7 +706,7 @@ void deref(char* q) {
|
706 | 706 | char x = *q; // $ deref=L714->L705->L706 // BAD
|
707 | 707 | }
|
708 | 708 |
|
709 |
| -void test35(unsigned long size, char* q) |
| 709 | +void test35(size_t size, char* q) |
710 | 710 | {
|
711 | 711 | char* p = new char[size];
|
712 | 712 | char* end = p + size; // $ alloc=L711
|
@@ -734,10 +734,10 @@ void test36(unsigned size, unsigned n) {
|
734 | 734 | }
|
735 | 735 | }
|
736 | 736 |
|
737 |
| -void test37(unsigned long n) |
| 737 | +void test37(size_t n) |
738 | 738 | {
|
739 | 739 | int *p = new int[n];
|
740 |
| - for (unsigned long i = n; i != 0u; i--) |
| 740 | + for (size_t i = n; i != 0u; i--) |
741 | 741 | {
|
742 | 742 | p[n - i] = 0; // GOOD
|
743 | 743 | }
|
@@ -833,17 +833,17 @@ void test7_no_field_flow(int size) {
|
833 | 833 | test7_callee_no_field_flow(begin, end);
|
834 | 834 | }
|
835 | 835 |
|
836 |
| -void test15_with_malloc(unsigned long index) { |
837 |
| - unsigned long size = index + 13; |
| 836 | +void test15_with_malloc(size_t index) { |
| 837 | + size_t size = index + 13; |
838 | 838 | if(size < index) {
|
839 | 839 | return;
|
840 | 840 | }
|
841 | 841 | int* newname = (int*)malloc(size);
|
842 | 842 | newname[index] = 0; // $ SPURIOUS: alloc=L841 deref=L842 // GOOD [FALSE POSITIVE]
|
843 | 843 | }
|
844 | 844 |
|
845 |
| -void test16_with_malloc(unsigned long index) { |
846 |
| - unsigned long size = index + 13; |
| 845 | +void test16_with_malloc(size_t index) { |
| 846 | + size_t size = index + 13; |
847 | 847 | if(size >= index) {
|
848 | 848 | int* newname = (int*)malloc(size);
|
849 | 849 | newname[index] = 0; // $ SPURIOUS: alloc=L848 deref=L849 // GOOD [FALSE POSITIVE]
|
|
0 commit comments