This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch releases/12.12
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/12.12 by this push:
     new 70178936842 procfs/heapcheck:fix bug,aviod '\n' to 0
70178936842 is described below

commit 70178936842f63418dcb53a982c4b0848e3e50e2
Author: anjiahao <[email protected]>
AuthorDate: Wed Mar 5 15:56:11 2025 +0800

    procfs/heapcheck:fix bug,aviod '\n' to 0
    
    The lines will end with \n to prevent atoi('\n') from always being 0. It is 
recommended to check the first byte directly.
    
    Signed-off-by: anjiahao <[email protected]>
---
 fs/procfs/fs_procfsproc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c
index 56068c67cd3..310bd63e5fb 100644
--- a/fs/procfs/fs_procfsproc.c
+++ b/fs/procfs/fs_procfsproc.c
@@ -966,12 +966,12 @@ static ssize_t proc_heapcheck_write(FAR struct 
proc_file_s *procfile,
                                     FAR const char *buffer,
                                     size_t buflen, off_t offset)
 {
-  switch (atoi(buffer))
+  switch (buffer[0])
     {
-      case 0:
+      case '0':
         tcb->flags &= ~TCB_FLAG_HEAP_CHECK;
         break;
-      case 1:
+      case '1':
         tcb->flags |= TCB_FLAG_HEAP_CHECK;
         break;
       default:

Reply via email to