Lines Matching refs:p
47 void myfoo(int *p);
48 void myfooint(int p);
52 int *p = malloc(12); in f1() local
57 int *p = malloc(12); in f2() local
58 free(p); in f2()
59 free(p); // expected-warning{{Attempt to free released memory}} in f2()
63 int *p = malloc(12); in f2_realloc_0() local
64 realloc(p,0); in f2_realloc_0()
65 realloc(p,0); // expected-warning{{Attempt to free released memory}} in f2_realloc_0()
69 int *p = malloc(12); in f2_realloc_1() local
70 int *q = realloc(p,0); // no-warning in f2_realloc_1()
75 char *p = (char*)malloc(size); in reallocNotNullPtr() local
76 if (p) { in reallocNotNullPtr()
77 char *q = (char*)realloc(p, sizeIn); in reallocNotNullPtr()
83 int *p = alloca(sizeof(int)); in allocaTest() local
87 int *p = _alloca(sizeof(int)); in winAllocaTest() local
91 int *p = __builtin_alloca(sizeof(int)); in allocaBuiltinTest() local
102 char *p = malloc(12); in reallocFails() local
103 char *r = realloc(p, 12+1); in reallocFails()
105 free(p); in reallocFails()
112 char *p = malloc(12); in reallocSizeZero1() local
113 char *r = realloc(p, 0); in reallocSizeZero1()
115 free(p); // expected-warning {{Attempt to free released memory}} in reallocSizeZero1()
122 char *p = malloc(12); in reallocSizeZero2() local
123 char *r = realloc(p, 0); in reallocSizeZero2()
125 free(p); // expected-warning {{Attempt to free released memory}} in reallocSizeZero2()
129 free(p); // expected-warning {{Attempt to free released memory}} in reallocSizeZero2()
133 char *p = malloc(12); in reallocSizeZero3() local
134 char *r = realloc(p, 0); in reallocSizeZero3()
237 int *p = malloc(0); in CheckUseZeroAllocatedNoWarn1() local
238 free(p); // no warning in CheckUseZeroAllocatedNoWarn1()
242 int *p = alloca(0); // no warning in CheckUseZeroAllocatedNoWarn2() local
246 int *p = _alloca(0); // no warning in CheckUseZeroWinAllocatedNoWarn2() local
251 int *p = malloc(0); in CheckUseZeroAllocatedNoWarn3() local
252 int *q = realloc(p, 8); // no warning in CheckUseZeroAllocatedNoWarn3()
257 int *p = realloc(0, 8); in CheckUseZeroAllocatedNoWarn4() local
258 *p = 1; // no warning in CheckUseZeroAllocatedNoWarn4()
259 free(p); in CheckUseZeroAllocatedNoWarn4()
263 int *p = malloc(0); in CheckUseZeroAllocated1() local
264 *p = 1; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocated1()
265 free(p); in CheckUseZeroAllocated1()
269 char *p = alloca(0); in CheckUseZeroAllocated2() local
270 return *p; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocated2()
274 char *p = _alloca(0); in CheckUseZeroWinAllocated2() local
275 return *p; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroWinAllocated2()
278 void UseZeroAllocated(int *p) { in UseZeroAllocated() argument
279 if (p) in UseZeroAllocated()
280 *p = 7; // expected-warning {{Use of memory allocated with size zero}} in UseZeroAllocated()
283 int *p = malloc(0); in CheckUseZeroAllocated3() local
284 UseZeroAllocated(p); in CheckUseZeroAllocated3()
289 char *p = valloc(0); in CheckUseZeroAllocated4() local
290 f(*p); // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocated4()
291 free(p); in CheckUseZeroAllocated4()
295 int *p = calloc(0, 2); in CheckUseZeroAllocated5() local
296 *p = 1; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocated5()
297 free(p); in CheckUseZeroAllocated5()
301 int *p = calloc(2, 0); in CheckUseZeroAllocated6() local
302 *p = 1; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocated6()
303 free(p); in CheckUseZeroAllocated6()
307 int *p = realloc(0, 0); in CheckUseZeroAllocated7() local
308 *p = 1; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocated7()
309 free(p); in CheckUseZeroAllocated7()
313 int *p = malloc(8); in CheckUseZeroAllocated8() local
314 int *q = realloc(p, 0); in CheckUseZeroAllocated8()
320 int *p = realloc(0, 0); in CheckUseZeroAllocated9() local
321 int *q = realloc(p, 0); in CheckUseZeroAllocated9()
331 char *p = malloc(s); in CheckUseZeroAllocatedPathNoWarn() local
334 *p = 1; // no warning in CheckUseZeroAllocatedPathNoWarn()
336 free(p); in CheckUseZeroAllocatedPathNoWarn()
344 char *p = malloc(s); in CheckUseZeroAllocatedPathWarn() local
347 *p = 1; // expected-warning {{Use of memory allocated with size zero}} in CheckUseZeroAllocatedPathWarn()
349 free(p); in CheckUseZeroAllocatedPathWarn()
357 char *p = malloc(8); in CheckUseZeroReallocatedPathNoWarn() local
358 char *q = realloc(p, s); in CheckUseZeroReallocatedPathNoWarn()
371 char *p = malloc(8); in CheckUseZeroReallocatedPathWarn() local
372 char *q = realloc(p, s); in CheckUseZeroReallocatedPathWarn()
384 static int *p = 0; in f3() local
385 p = malloc(12); in f3()
386 return p; // no-warning in f3()
405 int *p = malloc(12); in f6() local
406 if (!p) in f6()
409 free(p); in f6()
413 int *p = malloc(12); in f6_realloc() local
414 if (!p) in f6_realloc()
417 realloc(p,0); in f6_realloc()
675 void *p = malloc(2); in mallocCastToVoid() local
676 const void *cp = p; // not crash in mallocCastToVoid()
677 free(p); in mallocCastToVoid()
681 void *p = malloc(2); in mallocCastToFP() local
682 void (*fp)(void) = p; // not crash in mallocCastToFP()
683 free(p); in mallocCastToFP()
720 int *p = 0; in nullFree() local
721 free(p); // no warning - a nop in nullFree()
724 void paramFree(int *p) { in paramFree() argument
725 myfoo(p); in paramFree()
726 free(p); // no warning in paramFree()
727 myfoo(p); // expected-warning {{Use of memory after it is freed}} in paramFree()
731 int *p = malloc(12); in mallocEscapeRet() local
732 return p; // no warning in mallocEscapeRet()
736 int *p = malloc(12); in mallocEscapeFoo() local
737 myfoo(p); in mallocEscapeFoo()
742 int *p = malloc(12); in mallocEscapeFree() local
743 myfoo(p); in mallocEscapeFree()
744 free(p); in mallocEscapeFree()
748 int *p = malloc(12); in mallocEscapeFreeFree() local
749 myfoo(p); in mallocEscapeFreeFree()
750 free(p); in mallocEscapeFreeFree()
751 free(p); // expected-warning{{Attempt to free released memory}} in mallocEscapeFreeFree()
755 int *p = malloc(12); in mallocEscapeFreeUse() local
756 myfoo(p); in mallocEscapeFreeUse()
757 free(p); in mallocEscapeFreeUse()
758 myfoo(p); // expected-warning{{Use of memory after it is freed}} in mallocEscapeFreeUse()
762 void myalloc2(int **p);
765 int *p = malloc(12); in mallocEscapeFreeCustomAlloc() local
766 myfoo(p); in mallocEscapeFreeCustomAlloc()
767 free(p); in mallocEscapeFreeCustomAlloc()
768 p = myalloc(); in mallocEscapeFreeCustomAlloc()
769 free(p); // no warning in mallocEscapeFreeCustomAlloc()
773 int *p = malloc(12); in mallocEscapeFreeCustomAlloc2() local
774 myfoo(p); in mallocEscapeFreeCustomAlloc2()
775 free(p); in mallocEscapeFreeCustomAlloc2()
776 myalloc2(&p); in mallocEscapeFreeCustomAlloc2()
777 free(p); // no warning in mallocEscapeFreeCustomAlloc2()
788 int *p = malloc(12); in mallocEscapeMalloc() local
789 myfoo(p); in mallocEscapeMalloc()
790 p = malloc(12); in mallocEscapeMalloc()
794 int *p = malloc(12); in mallocMalloc() local
795 p = malloc(12); in mallocMalloc()
800 int *p = malloc(12); in mallocFreeMalloc() local
801 free(p); in mallocFreeMalloc()
802 p = malloc(12); in mallocFreeMalloc()
803 free(p); in mallocFreeMalloc()
807 int *p = malloc(12); in mallocFreeUse_params() local
808 free(p); in mallocFreeUse_params()
809 myfoo(p); //expected-warning{{Use of memory after it is freed}} in mallocFreeUse_params()
813 int *p = malloc(12); in mallocFreeUse_params2() local
814 free(p); in mallocFreeUse_params2()
815 myfooint(*p); //expected-warning{{Use of memory after it is freed}} in mallocFreeUse_params2()
819 int *p = malloc(12); in mallocFailedOrNot() local
820 if (!p) in mallocFailedOrNot()
821 free(p); in mallocFailedOrNot()
823 free(p); in mallocFailedOrNot()
831 int *p = malloc(12); in mallocReturnFreed() local
832 free(p); in mallocReturnFreed()
833 return p; // expected-warning {{Use of memory after it is freed}} in mallocReturnFreed()
843 void nonSymbolAsFirstArg(int *pp, struct StructWithInt *p);
846 struct StructWithInt *p = malloc(sizeof(struct StructWithInt)); in mallocEscapeFooNonSymbolArg() local
847 nonSymbolAsFirstArg(&p->g, p); in mallocEscapeFooNonSymbolArg()
852 int *p = malloc(12); in mallocFailedOrNotLeak() local
853 if (p == 0) in mallocFailedOrNotLeak()
860 char *p = malloc(12); in mallocAssignment() local
861 p = fooRetPtr(); in mallocAssignment()
870 int *p = valloc(12); in vallocEscapeFreeUse() local
871 myfoo(p); in vallocEscapeFreeUse()
872 free(p); in vallocEscapeFreeUse()
873 myfoo(p); // expected-warning{{Use of memory after it is freed}} in vallocEscapeFreeUse()
905 char *p = (char*)malloc(12); in globalArrayTest() local
906 ArrayG[0] = p; in globalArrayTest()
949 int *p = malloc(12); in testElemRegion2() local
950 *pp = p; in testElemRegion2()
955 int *p = malloc(12); in testElemRegion3() local
956 *pp = p; in testElemRegion3()
961 unsigned takePtrToPtr(int **p);
963 int *p = malloc(12); in PassTheAddrOfAllocatedData() local
965 if (takePtrToPtr(&p)) in PassTheAddrOfAllocatedData()
967 free(p); // no warning in PassTheAddrOfAllocatedData()
971 int *p; member
975 int *p = malloc(12); in foo2() local
977 px->p = p; in foo2()
981 free(p); in foo2()
987 px->p = 0; in RegInvalidationDetect1()
993 int *p = malloc(12); in RegInvalidationGiveUp1() local
995 px->p = p; in RegInvalidationGiveUp1()
1000 int *p = malloc(12); in RegInvalidationDetect2() local
1001 pp = &p; in RegInvalidationDetect2()
1008 struct xx *p = malloc(12); in mallocExit() local
1011 free(p); in mallocExit()
1021 struct xx *p = malloc(12); in mallocAssert() local
1024 free(p); in mallocAssert()
1029 char *p = malloc(12); in doNotInvalidateWhenPassedToSystemCalls() local
1030 strlen(p); in doNotInvalidateWhenPassedToSystemCalls()
1031 strcpy(p, s); in doNotInvalidateWhenPassedToSystemCalls()
1032 strcpy(s, p); in doNotInvalidateWhenPassedToSystemCalls()
1033 strcpy(p, p); in doNotInvalidateWhenPassedToSystemCalls()
1034 memcpy(p, s, 1); in doNotInvalidateWhenPassedToSystemCalls()
1035 memcpy(s, p, 1); in doNotInvalidateWhenPassedToSystemCalls()
1036 memcpy(p, p, 1); in doNotInvalidateWhenPassedToSystemCalls()
1041 char *p = malloc(12); in escapeSourceContents() local
1042 memcpy(s, &p, 12); // no warning in escapeSourceContents()
1059 int *p = (int *)malloc(4); in invalidateDestinationContents() local
1060 memcpy(&p, &null, sizeof(int *)); in invalidateDestinationContents()
1077 char *p = malloc(12); in symbolLostWithStrcpy() local
1078 p = strcpy(p, s); in symbolLostWithStrcpy()
1079 free(p); in symbolLostWithStrcpy()
1091 char *p = malloc(12); in symbolLostWithStrcpy_InlineStrcpyVersion() local
1092 …p = ((__builtin_object_size (p, 0) != (size_t) -1) ? __builtin___strcpy_chk (p, s, __builtin_objec… in symbolLostWithStrcpy_InlineStrcpyVersion()
1093 free(p); in symbolLostWithStrcpy_InlineStrcpyVersion()
1100 int *p; in specialMalloc() local
1101 p = malloc( n+8 ); in specialMalloc()
1102 if( p ){ in specialMalloc()
1103 p[0] = n; in specialMalloc()
1104 p++; in specialMalloc()
1106 return p; in specialMalloc()
1218 char *p = malloc(100); in my_main_no_warning() local
1219 setvbuf(stdout, p, 0, 100); in my_main_no_warning()
1223 char *p = malloc(100); in my_main_no_warning2() local
1224 setbuf(__stdoutp, p); in my_main_no_warning2()
1228 char *p = malloc(100); in my_main_warn() local
1229 setvbuf(f, p, 0, 100); in my_main_warn()
1277 struct rdar11269741_a_t *p = (struct rdar11269741_a_t *) malloc(sizeof(*p)); in rdar11269741() local
1278 p->n = o; in rdar11269741()
1279 return p->n.m; // expected-warning {{leak}} in rdar11269741()
1344 int *p; in dependsOnValueOfPtr() local
1347 p = g; in dependsOnValueOfPtr()
1349 p = malloc(12); in dependsOnValueOfPtr()
1352 if (p != g) in dependsOnValueOfPtr()
1353 free(p); in dependsOnValueOfPtr()
1415 char *p = (char*)malloc(12); in localArrayTest() local
1417 ArrayL[0] = p; in localArrayTest()
1477 void freeButNoMalloc(int *p, int x){ in freeButNoMalloc() argument
1479 free(p); in freeButNoMalloc()
1482 free(p); // expected-warning {{Attempt to free released memory}} in freeButNoMalloc()
1486 char *p; member
1491 char *b = realloc(a->p, size); in reallocButNoMalloc()
1492 char *m = realloc(a->p, size); // expected-warning {{Attempt to free released memory}} in reallocButNoMalloc()
1495 return a->p; // no-warning in reallocButNoMalloc()
1501 char *b = realloc(a->p, size); in reallocButNoMallocPR13674()
1504 a->p = b; in reallocButNoMallocPR13674()
1540 char *p = malloc(1); in testPassConstPointerIndirectly() local
1541 p++; in testPassConstPointerIndirectly()
1542 memcmp(p, p, sizeof(&p)); in testPassConstPointerIndirectly()
1548 hp.p = malloc(10); in testPassConstPointerIndirectlyStruct()
1555 ss.p = malloc(1); in testPassToSystemHeaderFunctionIndirectlyStruct()
1563 ss.p = malloc(1); in testPassToSystemHeaderFunctionIndirectlyStructFree()
1565 free(ss.p); in testPassToSystemHeaderFunctionIndirectlyStructFree()
1569 int *p[1]; in testPassToSystemHeaderFunctionIndirectlyArray() local
1570 p[0] = malloc(sizeof(int)); in testPassToSystemHeaderFunctionIndirectlyArray()
1571 fakeSystemHeaderCallIntPtr(p); // invalidates p, making p[0] unreachable in testPassToSystemHeaderFunctionIndirectlyArray()
1577 int *p[1]; in testPassToSystemHeaderFunctionIndirectlyArrayFree() local
1578 p[0] = malloc(sizeof(int)); in testPassToSystemHeaderFunctionIndirectlyArrayFree()
1579 fakeSystemHeaderCallIntPtr(p); // invalidates p, making p[0] unreachable in testPassToSystemHeaderFunctionIndirectlyArrayFree()
1580 free(p[0]); in testPassToSystemHeaderFunctionIndirectlyArrayFree()
1599 __int64_t *p = malloc(sizeof(__int64_t)*2); in testOffsetOfRegionFreed2() local
1600 p += 1; in testOffsetOfRegionFreed2()
1601 …free(p); // expected-warning{{Argument to free() is offset by 8 bytes from the start of memory all… in testOffsetOfRegionFreed2()
1611 int *p = malloc(sizeof(int)*2); in testOffsetOfRegionFreedAfterFunctionCall() local
1612 p += 1; in testOffsetOfRegionFreedAfterFunctionCall()
1613 myfoo(p); in testOffsetOfRegionFreedAfterFunctionCall()
1614 …free(p); // expected-warning{{Argument to free() is offset by 4 bytes from the start of memory all… in testOffsetOfRegionFreedAfterFunctionCall()
1630 __int64_t *p = malloc(sizeof(__int64_t)*2); in freeOffsetPointerPassedToFunction() local
1631 p[1] = 0; in freeOffsetPointerPassedToFunction()
1632 p += 1; in freeOffsetPointerPassedToFunction()
1633 myfooint(*p); // not passing the pointer, only a value pointed by pointer in freeOffsetPointerPassedToFunction()
1634 …free(p); // expected-warning {{Argument to free() is offset by 8 bytes from the start of memory al… in freeOffsetPointerPassedToFunction()
1659 int *p = &array[0]; in testOffsetZeroDoubleFree() local
1660 free(p); in testOffsetZeroDoubleFree()
1717 char *p = (char*) smallocNoWarn(len + 1); in dupstrNoWarn() local
1718 strcpy(p, s); // no-warning in dupstrNoWarn()
1719 return p; in dupstrNoWarn()
1733 int *p = data ?: (int*)malloc(32); // no warning in radar15580979() local
1734 return p; in radar15580979()
1756 int *p; member
1763 s.p = malloc(sizeof(int)); in testConstEscapeThroughAnotherField()
1780 void *p = (void *)fnptr; in freeIndirectFunctionPtr() local
1781 free(p); // expected-warning {{Argument to free() is a function pointer}} in freeIndirectFunctionPtr()
1843 char *p = (char *)realloc(buf, 2 * BUFSIZE); in MEM34_C() local
1846 if (p == NULL) {
1866 void testMallocWithParam(int **p) { in testMallocWithParam() argument
1867 *p = (int*) malloc(sizeof(int)); in testMallocWithParam()
1868 *p = 0; // FIXME: should warn here in testMallocWithParam()
1871 void testMallocWithParam_2(int **p) { in testMallocWithParam_2() argument
1872 *p = (int*) malloc(sizeof(int)); // no-warning in testMallocWithParam_2()
1876 int *p = malloc(4); in testPassToSystemHeaderFunctionIndirectly() local
1877 p++; in testPassToSystemHeaderFunctionIndirectly()
1878 fakeSystemHeaderCallInt(p); in testPassToSystemHeaderFunctionIndirectly()
1894 int *p = (int *)malloc(x); in testExtent() local
1895 clang_analyzer_dumpExtent(p); in testExtent()
1897 free(p); in testExtent()