Fix snprintf truncation warnings
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
+4
-2
@@ -555,7 +555,8 @@ static void NavigateToParentDirectory(void)
|
|||||||
static void NavigateToDirectory(const char* dirName)
|
static void NavigateToDirectory(const char* dirName)
|
||||||
{
|
{
|
||||||
char newPath[512];
|
char newPath[512];
|
||||||
snprintf(newPath, sizeof(newPath), "%s/%s", app.browserPath, dirName);
|
int written = snprintf(newPath, sizeof(newPath), "%s/%s", app.browserPath, dirName);
|
||||||
|
if (written < 0 || written >= (int)sizeof(newPath)) return; // Path too long
|
||||||
if (DirectoryExists(newPath)) ScanDirectory(newPath);
|
if (DirectoryExists(newPath)) ScanDirectory(newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +565,8 @@ static void LoadSelectedFile(void)
|
|||||||
if (app.browserSelected < 0 || app.browserSelected >= app.browserFileCount) return;
|
if (app.browserSelected < 0 || app.browserSelected >= app.browserFileCount) return;
|
||||||
|
|
||||||
char filePath[512];
|
char filePath[512];
|
||||||
snprintf(filePath, sizeof(filePath), "%s/%s", app.browserPath, app.browserFiles[app.browserSelected]);
|
int written = snprintf(filePath, sizeof(filePath), "%s/%s", app.browserPath, app.browserFiles[app.browserSelected]);
|
||||||
|
if (written < 0 || written >= (int)sizeof(filePath)) return; // Path too long
|
||||||
|
|
||||||
if (app.browserIsDir[app.browserSelected]) {
|
if (app.browserIsDir[app.browserSelected]) {
|
||||||
NavigateToDirectory(app.browserFiles[app.browserSelected]);
|
NavigateToDirectory(app.browserFiles[app.browserSelected]);
|
||||||
|
|||||||
Reference in New Issue
Block a user