Skip to content

Commit 9ded535

Browse files
committed
fix: use strlen
1 parent f9c560d commit 9ded535

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/kasa_crypt/_crypt_impl.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import cython
22

33
from libc.stdlib cimport malloc
4+
from libc.string cimport strlen
45

56

67
cdef extern from "crypt_wrapper.h":
78
void _encrypt_into(const char * unencrypted, char * encrypted)
89
void _decrypt_into(const char * encrypted, char * unencrypted)
910

1011
cdef char* _decrypt(const char *encrypted):
11-
cdef char* unencrypted = <char *> malloc(((len(encrypted)) + 1) * sizeof(char))
12+
cdef char* unencrypted = <char *> malloc(((strlen(encrypted)) + 1) * sizeof(char))
1213
if not unencrypted:
1314
return NULL # malloc failed
1415
_decrypt_into(encrypted, unencrypted)
1516
return unencrypted
1617

1718
cdef char* _encrypt(const char *unencrypted):
18-
cdef char* encrypted = <char *> malloc(((len(unencrypted)) + 1) * sizeof(char))
19+
cdef char* encrypted = <char *> malloc(((strlen(unencrypted)) + 1) * sizeof(char))
1920
if not encrypted:
2021
return NULL # malloc failed
2122
_encrypt_into(unencrypted, encrypted)

0 commit comments

Comments
 (0)