# Prove the absence of undefined behaviors

## Fix the undefined behavior

{% hint style="info" %}
Proving the absence of undefined behaviors is straightforward with TrustInSoft CI => fix all the undefined behaviors until the test shows "No undefined behaviors".

After this point, you may relax and wait for the next code change and analysis result or decide to [go beyond your test suite](https://docs.ci.trust-in-soft.com/tutorial/go-beyond-your-test-suite).
{% endhint %}

On the previous step, we realized that the code should not allocate a buffer of constant size but one of the same size as the input string. Fixing this should remove the undefined behavior.

To save you some time, we've prepared the code change in a dedicated branch called **`fix-memory-alloc`**.&#x20;

You'll merge this branch to your master branch via a pull request. Here are the steps with a screen recording at the end:

**1.** On GitHub, click on **New pull request** on your fork project.

**2.** Change the **compare branch** to **fix-memory-alloc**.

**3.** Change the **base repository** to your **fork project**.

**4.** Review the changes in the diff.\
\
The `caesar_encrypt` and `caesar_decrypt` functions take the length of the input string as an additional argument, and the code allocates a buffer `buf` of the same size `str_len` as the input string.

**5.** Click on **Create pull request**, and again to confirm.

**6.** Click on **Merge pull request**, then **Confirm merge**.

<div align="center"><img src="https://3982345336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpYF4Rmm1tt0M5Cn4E0%2F-LrK0138NdlBuG7HD6Rv%2F-LrK10htOlztgPcuEpYp%2F2019-10-16_16-37-44%20(1).gif?alt=media&#x26;token=88f85734-1502-4325-a5a6-4c0b9a0d0646" alt=""></div>

You have just merged the code change to your master branch!

## Observe the updated analysis result in TrustInSoft CI

**1.** In TrustInSoft CI, click on `master` to go back to the Reference page:

![](https://3982345336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpYF4Rmm1tt0M5Cn4E0%2F-Mdpwa9nQ_63v5FLvUQs%2F-MdpxYBtnBcAegAKwD20%2Fimage.png?alt=media\&token=42db9224-69cd-4451-8dbd-b9f12f1f9613)

**2.** If you did not change the Project settings, a new build should have been trigger on the new commit as described in the screenshot above. Otherwise you can still run a new build with the `Run new build` button in the top-right corner.

**3.** You can already see the analysis is now green, which mean no undefined behavior has been detected. By clicking on the `#2` build, you can double check this fact:

![](https://3982345336-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpYF4Rmm1tt0M5Cn4E0%2F-Mdpwa9nQ_63v5FLvUQs%2F-MdpyPhYzLxxIaZqNSPq%2Fimage.png?alt=media\&token=4d2f1f75-322f-4f94-aabd-088c8908bbd4)

{% hint style="success" %}
Since no undefined behavior was found, you have proved the absence of undefined behaviors on the tested path!
{% endhint %}
