File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -292,12 +292,12 @@ void library_statement(struct basic_ctx* ctx)
292292
293293 /* Load the library file from VFS */
294294 size_t library_len = file_info -> size ;
295- char * temp_library = kmalloc (library_len );
295+ char * temp_library = kmalloc (library_len + 1 );
296296 if (!temp_library ) {
297297 tokenizer_error_print (ctx , "Not enough memory to load library file" );
298298 return ;
299299 }
300- char * clean_library = kmalloc (library_len );
300+ char * clean_library = kmalloc (library_len + 1 );
301301 if (!clean_library ) {
302302 kfree_null (& temp_library );
303303 tokenizer_error_print (ctx , "Not enough memory to load library file" );
Original file line number Diff line number Diff line change @@ -234,9 +234,9 @@ char* strdup(const char* string)
234234 if (!string ) {
235235 return NULL ;
236236 }
237- uint32_t len = strlen (string ) + 1 ;
238- char * result = kmalloc (len );
239- strlcpy (result , string , len );
237+ uint32_t len = strlen (string );
238+ char * result = kmalloc (len + 1 );
239+ strlcpy (result , string , len + 1 );
240240 * (result + len ) = 0 ;
241241 return result ;
242242}
@@ -246,9 +246,9 @@ char* gc_strdup(const char* string)
246246 if (!string ) {
247247 return NULL ;
248248 }
249- uint32_t len = strlen (string ) + 1 ;
250- char * result = kmalloc (len );
251- strlcpy (result , string , len );
249+ uint32_t len = strlen (string );
250+ char * result = kmalloc (len + 1 );
251+ strlcpy (result , string , len + 1 );
252252 * (result + len ) = 0 ;
253253
254254 if (gc_list == NULL ) {
You can’t perform that action at this time.
0 commit comments