@@ -515,7 +515,6 @@ static int XHost_LintEntries(xhost_ctx_t *pCtx)
515515 XASSERT ((XHost_InitContext (pCtx , XFALSE ) > 0 ), xthrowe ("Failed to init context" ));
516516
517517 int nCount = 0 ;
518-
519518 while (XFile_GetLine (& pCtx -> file , pCtx -> sLine , sizeof (pCtx -> sLine )) > 0 )
520519 {
521520 xhost_entry_t entry ;
@@ -530,14 +529,21 @@ static int XHost_LintEntries(xhost_ctx_t *pCtx)
530529 xthrow ("Failed to add line to hosts buffer (%s)" , XSTRERR ));
531530
532531 for (size_t i = 0 ; i < nPadding + pCtx -> nTabSize ; i ++ )
533- XString_Append (& pCtx -> hosts , " " );
532+ {
533+ XASSERT ((XString_Add (& pCtx -> hosts , XSTR_SPACE , 1 ) >= 0 ),
534+ xthrow ("Failed to add spaces to the buffer (%s)" , XSTRERR ));
535+ }
534536
535- XString_Append (& pCtx -> hosts , "%s" , entry .sHost );
537+ XASSERT ((XString_Append (& pCtx -> hosts , "%s" , entry .sHost ) >= 0 ),
538+ xthrow ("Failed to add host line to the buffer (%s)" , XSTRERR ));
536539
537540 if (xstrused (entry .sComment ))
538- XString_Append (& pCtx -> hosts , " # %s" , entry .sComment );
541+ XASSERT ((XString_Append (& pCtx -> hosts , " # %s" , entry .sComment ) >= 0 ),
542+ xthrow ("Failed to add comment line to hosts buffer (%s)" , XSTRERR ));
543+
544+ XASSERT ((XString_Add (& pCtx -> hosts , XSTR_NEW_LINE , 1 ) >= 0 ),
545+ xthrow ("Failed to add line to hosts buffer (%s)" , XSTRERR ));
539546
540- XString_Add (& pCtx -> hosts , "\n" , 1 );
541547 nCount ++ ;
542548 continue ;
543549 }
0 commit comments