Use safer sizeof variant in malloc
[openssl.git] / crypto / LPdir_unix.c
index bead6abd71563b0f8fc162d44f528a58cf20c01a..3a14da19b17b4617727f6caed0151fd06e153702 100644 (file)
@@ -78,12 +78,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
 
     errno = 0;
     if (*ctx == NULL) {
-        *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
+        *ctx = malloc(sizeof(**ctx));
         if (*ctx == NULL) {
             errno = ENOMEM;
             return 0;
         }
-        memset(*ctx, '\0', sizeof(LP_DIR_CTX));
+        memset(*ctx, '\0', sizeof(**ctx));
 
         (*ctx)->dir = opendir(directory);
         if ((*ctx)->dir == NULL) {