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

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


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

commit 60dc94b909a11323ef60d2b78c981fbe5532537c
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