From 7bb273d924faae19ac4404910f9901b43ebe577a Mon Sep 17 00:00:00 2001 From: tudors Date: Fri, 8 Dec 2023 17:08:24 +0000 Subject: [PATCH 1/4] Update background.tex --- background/background.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background/background.tex b/background/background.tex index 45a358a..27cb1c9 100644 --- a/background/background.tex +++ b/background/background.tex @@ -306,7 +306,7 @@ \subsection{Asserts} Here is a quick example with an assert. Let's say that we are writing code using memcpy. We would want to put an assert before that checks whether my two memory regions overlap. -If they do overlap, memcpy runs into undefined behavior, so we want to catch that problem than later. +If they do overlap, memcpy runs into undefined behavior, so we want to catch that problem earlier rather than later. \begin{lstlisting}[language=C] assert(!(src < dest+n && dest < src+n)); //Checks overlap From a4cc2c7bb0c560f03192d0999a80cd40e6af4bb6 Mon Sep 17 00:00:00 2001 From: tudors Date: Fri, 8 Dec 2023 23:26:40 +0000 Subject: [PATCH 2/4] Update background/background.tex --- background/background.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background/background.tex b/background/background.tex index 27cb1c9..e0298d0 100644 --- a/background/background.tex +++ b/background/background.tex @@ -306,7 +306,7 @@ \subsection{Asserts} Here is a quick example with an assert. Let's say that we are writing code using memcpy. We would want to put an assert before that checks whether my two memory regions overlap. -If they do overlap, memcpy runs into undefined behavior, so we want to catch that problem earlier rather than later. +If they do overlap, memcpy runs into undefined behavior, so we want to catch that problem sooner rather than later. \begin{lstlisting}[language=C] assert(!(src < dest+n && dest < src+n)); //Checks overlap From cb88cf510e8d386bc45ef66c5539007c9efa54e9 Mon Sep 17 00:00:00 2001 From: tudors Date: Fri, 8 Dec 2023 23:28:16 +0000 Subject: [PATCH 3/4] Update background/background.tex --- background/background.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background/background.tex b/background/background.tex index e0298d0..e89a803 100644 --- a/background/background.tex +++ b/background/background.tex @@ -306,7 +306,7 @@ \subsection{Asserts} Here is a quick example with an assert. Let's say that we are writing code using memcpy. We would want to put an assert before that checks whether my two memory regions overlap. -If they do overlap, memcpy runs into undefined behavior, so we want to catch that problem sooner rather than later. +If they do overlap, memcpy runs into undefined behavior, so we want to discover that problem sooner rather than later. \begin{lstlisting}[language=C] assert(!(src < dest+n && dest < src+n)); //Checks overlap From be6ecacabd7f1b81801be977979a2c3b8e875ea7 Mon Sep 17 00:00:00 2001 From: tudors Date: Sat, 9 Dec 2023 00:06:21 +0000 Subject: [PATCH 4/4] Update background/background.tex --- background/background.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background/background.tex b/background/background.tex index e89a803..0d40433 100644 --- a/background/background.tex +++ b/background/background.tex @@ -309,7 +309,7 @@ \subsection{Asserts} If they do overlap, memcpy runs into undefined behavior, so we want to discover that problem sooner rather than later. \begin{lstlisting}[language=C] -assert(!(src < dest+n && dest < src+n)); //Checks overlap +assert( src+n < dest || src >= dest + n); // source should finish before the destination or the source starts after the end of destination memcpy(dest, src, n); \end{lstlisting}