From e3da8a1fd9d76456f42731a05cd5162036179a97 Mon Sep 17 00:00:00 2001 From: Amir Livneh Date: Thu, 21 Mar 2019 14:06:02 -0400 Subject: [PATCH] Add example for E.28 (#1385) --- CppCoreGuidelines.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index f562b1f..eaa0f18 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -16079,7 +16079,15 @@ When did you last test the return value of `printf()`? ##### Example, bad - ??? + int last_err; + + void f(int n) + { + // ... + p = static_cast(malloc(n * sizeof(X))); + if (!p) last_err = -1; // error if memory is exhausted + // ... + } ##### Note