Skip to content

メモリ解放と入力検証まわりの修正#32

Merged
gaotoast merged 6 commits intomainfrom
release/submission-1
Feb 22, 2026
Merged

メモリ解放と入力検証まわりの修正#32
gaotoast merged 6 commits intomainfrom
release/submission-1

Conversation

@gaotoast
Copy link
Owner

概要

メモリ解放処理と入力検証まわりの不具合修正・改善

関連issue

なし

変更点

  • macOS / Linux 双方でコンパイル時のスレッド数を 1 に固定し、提出環境向けに挙動を単純化
  • free_scene 関数をダブルポインタ対応に変更し、解放後に NULL クリア
  • 正規化ベクトル検証用の NORM_EPSILON を追加し、浮動小数誤差を考慮したバリデーションに改善
  • オブジェクト生成失敗時のエラーメッセージを print_error(ERR_MSG_MALLOC) に統一
  • ESCキーの重複定義を削除

懸念点

  • NORM_EPSILON の値によっては、シーンによって判定が厳しすぎる / 緩すぎる可能性がある

レビュー観点

  • メモリ解放処理(free_scene 周辺)がリークやダブルフリーを起こさないこと
  • 正規化ベクトルの検証が想定どおりに機能し、既存シーンでエラーになりすぎていないこと
  • 提出環境で問題なくビルド・実行できること

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors memory management and input validation for submission environment compatibility. It fixes memory leak risks, standardizes error handling, and adjusts floating-point tolerance for normalized vector validation.

Changes:

  • Hardcoded compilation thread count to 1 for both macOS and Linux to simplify behavior in submission environments
  • Refactored free_scene to use double pointer pattern, automatically setting pointer to NULL after freeing to prevent use-after-free bugs
  • Added NORM_EPSILON constant (1e-3) for normalized vector validation with better floating-point tolerance
  • Standardized malloc failure error messages to use print_error(ERR_MSG_MALLOC) instead of perror
  • Removed duplicate ESC_KEY definition from config.h

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Makefile Hardcoded THREADS to 1 for consistent compilation behavior in submission environment
includes/config.h Added NORM_EPSILON (1e-3) for vector validation; removed duplicate ESC_KEY definition
includes/miniRT.h Updated free_scene signature to accept double pointer
srcs/free.c Refactored free_scene to use double pointer pattern and set pointer to NULL after freeing
srcs/parsing/parse.c Updated free_scene calls to pass address of scene pointer
srcs/parsing/object_list.c Standardized malloc error message from perror to print_error(ERR_MSG_MALLOC)
srcs/parsing/validate_values.c Changed normalized vector validation to use NORM_EPSILON instead of EPSILON

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gaotoast gaotoast changed the title 初回提出用の修正とリファクタリング メモリ解放と入力検証まわりの修正 Feb 22, 2026
Copy link
Collaborator

@k1n4mur4 k1n4mur4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いいと思います。

@gaotoast gaotoast merged commit 7866e38 into main Feb 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants