diff options
author | Ryan <ryebread761@gmail.com> | 2016-08-17 13:25:32 -0600 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-08-17 21:25:32 +0200 |
commit | 21c4be47790c230cf5a321aeabb5c07ad57f0522 (patch) | |
tree | 844d4aa496c4669d0040c9cd95a33843cff37fda /c.html.markdown | |
parent | a0b6af45345b957c749dd2cd2e54117006af08be (diff) |
Remove undefined behavior (#2332)
Diffstat (limited to 'c.html.markdown')
-rw-r--r-- | c.html.markdown | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/c.html.markdown b/c.html.markdown index babf0954..92f07fe2 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -449,7 +449,8 @@ int main (int argc, char** argv) int size = 10; int *my_arr = malloc(sizeof(int) * size); // Add an element to the array - my_arr = realloc(my_arr, ++size); + size++; + my_arr = realloc(my_arr, sizeof(int) * size); my_arr[10] = 5; // Dereferencing memory that you haven't allocated gives |