Skip to content

Commit 90dc023

Browse files
authored
posix.cfg: Fixed FP for getdelim and array (#6125)
This fix is similar to #6108
1 parent 88df55c commit 90dc023

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

cfg/posix.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5259,7 +5259,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
52595259
<not-uninit/>
52605260
<valid>0:255</valid>
52615261
</arg>
5262-
<arg nr="4" direction="in">
5262+
<arg nr="4" direction="inout">
52635263
<not-null/>
52645264
<not-uninit/>
52655265
</arg>

test/cfg/posix.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,8 @@ typedef struct {
913913
} S_memalign;
914914

915915
S_memalign* posix_memalign_memleak(size_t n) { // #12248
916-
S_memalign* s = malloc(sizeof(*s));
917-
s->N = n;
916+
S_memalign* s = malloc(sizeof(*s));
917+
s->N = n;
918918
if (0 != posix_memalign((void**)&s->data, 16, n * sizeof(int))) {
919919
free(s);
920920
return NULL;
@@ -1079,6 +1079,26 @@ void memleak_getline_array(FILE* stream) { // #12498
10791079
free(a[1]);
10801080
}
10811081

1082+
void memleak_getdelim(int delim) {
1083+
char *line = NULL;
1084+
size_t size = 0;
1085+
getdelim(&line, &size, delim, stdin);
1086+
// cppcheck-suppress memleak
1087+
line = NULL;
1088+
getdelim(&line, &size, delim, stdin);
1089+
// cppcheck-suppress memleak
1090+
line = NULL;
1091+
}
1092+
1093+
void memleak_getdelim_array(FILE* stream, int delim) {
1094+
char* a[2] = { 0 };
1095+
size_t n;
1096+
getdelim(&a[0], &n, delim, stream);
1097+
getdelim(&a[1], &n, delim, stream);
1098+
free(a[0]);
1099+
free(a[1]);
1100+
}
1101+
10821102
void * identicalCondition_mmap(int fd, size_t size) // #9940
10831103
{
10841104
void* buffer = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

0 commit comments

Comments
 (0)