Fix: don't print the contents of a NULL pointer

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1423 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
sth 2003-09-06 13:36:59 +00:00
parent 1decd28185
commit 4f580598b0
1 changed files with 5 additions and 2 deletions

View File

@ -49,7 +49,7 @@ void print_boolean(FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_V
void print_generic(FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_VOID_PTR arg)
{
CK_ULONG i;
if(size > 0) {
if(size > 0 && value != NULL) {
fprintf(f, "[size : 0x%lX (%ld)]\n ", size, size);
for(i = 0; i < size; i++) {
if (i != 0) {
@ -61,7 +61,10 @@ void print_generic(FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_V
fprintf(f, "%02X", ((CK_BYTE *)value)[i]);
}
} else {
fprintf(f, "EMPTY");
if (value != NULL)
fprintf(f, "EMPTY");
else
fprintf(f, "NULL [size : 0x%lX (%ld)]", size, size);
}
fprintf(f, "\n");
}