gpgscm: Avoid truncating pointers.

* tests/gpgscm/scheme.c (_alloc_cellseg): Avoid truncating pointers on
systems where sizeof(unsigned long) < sizeof(void *).

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-11-29 13:31:38 +01:00
parent f6728d13e8
commit e062bc4da8
1 changed files with 3 additions and 2 deletions

View File

@ -29,6 +29,7 @@
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <float.h>
#include <ctype.h>
@ -615,8 +616,8 @@ _alloc_cellseg(scheme *sc, size_t len, void **alloc, pointer *cells)
*alloc = cp;
/* adjust in TYPE_BITS-bit boundary */
if (((unsigned long) cp) % adj != 0)
cp = (void *) (adj * ((unsigned long) cp / adj + 1));
if (((uintptr_t) cp) % adj != 0)
cp = (void *) (adj * ((uintptr_t) cp / adj + 1));
*cells = cp;
return 0;