mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(coverity/497375): f_strpart cast overflow (#30773)
Problem: Casting long to int introduces risk of overflow. Solution: Work with all int64_t (long) rather than casting back and forth.
This commit is contained in:
		| @@ -2838,10 +2838,10 @@ void f_strpart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) | ||||
|   } | ||||
|  | ||||
|   if (argvars[2].v_type != VAR_UNKNOWN && argvars[3].v_type != VAR_UNKNOWN) { | ||||
|     int off; | ||||
|     int64_t off; | ||||
|  | ||||
|     // length in characters | ||||
|     for (off = (int)n; off < (int)slen && len > 0; len--) { | ||||
|     for (off = n; off < (int64_t)slen && len > 0; len--) { | ||||
|       off += utfc_ptr2len(p + off); | ||||
|     } | ||||
|     len = off - n; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Devon Gardner
					Devon Gardner