Feature/pratica03#3
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0125b74da3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| Agenda criar_agenda(int tamanho) { | ||
| Agenda agenda; | ||
| agenda.tamanho = tamanho; |
There was a problem hiding this comment.
Cap agenda size to fixed contact array limit
Agenda stores contacts in a fixed contatos[LIMITE] buffer, but criar_agenda accepts any tamanho and adicionar_contato enforces only quantidade == tamanho. If a caller creates an agenda with tamanho > LIMITE (100), inserts beyond index 99 will write out of bounds and corrupt memory. Clamp tamanho to LIMITE (or enforce quantidade < LIMITE on insert) before using it as capacity.
Useful? React with 👍 / 👎.
|
|
||
| void conta_depositar(Conta *conta, double valor) | ||
| { | ||
| conta->saldo += valor; |
There was a problem hiding this comment.
Reject negative values in deposits
conta_depositar applies saldo += valor without validating the sign, so passing a negative amount silently withdraws funds and bypasses the overdraft logic in conta_sacar. In any flow where valor comes from user input or external data, this produces incorrect balances. Guard deposits with valor > 0 before mutating the account.
Useful? React with 👍 / 👎.
| if (conta->saldo >= valor) | ||
| { | ||
| conta->saldo -= valor; |
There was a problem hiding this comment.
The withdrawal check if (conta->saldo >= valor) treats negative valor as valid (the condition is usually true), and then saldo -= valor increases balance instead of decreasing it. This allows callers to credit money via the withdrawal path and breaks accounting correctness when inputs are not prevalidated upstream. Ensure withdrawals require valor > 0 before evaluating available balance.
Useful? React with 👍 / 👎.
No description provided.