Question: In the following code, what is the first line that introduces a memory leak into the program? (Type the line number into the box below.)
In the following code, what is the first line that introduces a memory leak into the program? (Type the line number into the box below.)
1: #include
2: #include
3: #include
4:
5: int main(void)
6: {
7: char *word1 = NULL;
8: char *word2 = NULL;
9:
10: word1 = malloc(sizeof(char) * 10);
11: word2 = malloc(sizeof(char) * 12);
12:
13: word1 = "bramble";
14: word2 = word1;
15: word1 = malloc(sizeof(char) * 10);
16:
17: word1 = NULL;
18: word2 = NULL;
19:
20: return 0;
21: }
it's not at line 14 or 20.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
