windows: ACH: Error handling cleanup

This commit is contained in:
Tom Dewey 2024-08-09 16:10:34 +01:00 committed by Tom Dewey
parent 180ff193aa
commit 31249e6e59

View file

@ -29,7 +29,8 @@ struct AcceleratedCryptographicHash::impl {
0))) 0)))
{ {
qDebug() << "BCryptOpenAlgorithmProvider returned Error " << status; qDebug() << "BCryptOpenAlgorithmProvider returned Error " << status;
goto Cleanup; cleanup();
return;
} }
//calculate the size of the buffer to hold the hash object //calculate the size of the buffer to hold the hash object
@ -42,7 +43,8 @@ struct AcceleratedCryptographicHash::impl {
0))) 0)))
{ {
qDebug() << "BCryptGetProperty returned Error " << status; qDebug() << "BCryptGetProperty returned Error " << status;
goto Cleanup; cleanup();
return;
} }
//allocate the hash object on the heap //allocate the hash object on the heap
@ -50,7 +52,8 @@ struct AcceleratedCryptographicHash::impl {
if(NULL == pbHashObject) if(NULL == pbHashObject)
{ {
qDebug() << "memory allocation failed"; qDebug() << "memory allocation failed";
goto Cleanup; cleanup();
return;
} }
//calculate the length of the hash //calculate the length of the hash
@ -63,7 +66,8 @@ struct AcceleratedCryptographicHash::impl {
0))) 0)))
{ {
qDebug() << "BCryptGetProperty returned Error " << status; qDebug() << "BCryptGetProperty returned Error " << status;
goto Cleanup; cleanup();
return;
} }
//allocate the hash buffer on the heap //allocate the hash buffer on the heap
@ -92,7 +96,7 @@ struct AcceleratedCryptographicHash::impl {
} }
~impl() { ~impl() {
cleanup() cleanup();
} }
void cleanup() { void cleanup() {
@ -127,7 +131,8 @@ struct AcceleratedCryptographicHash::impl {
0))) 0)))
{ {
qDebug() << "BCryptHashData returned Error " << status; qDebug() << "BCryptHashData returned Error " << status;
goto Cleanup; cleanup();
return;
} }
} }
@ -145,7 +150,7 @@ struct AcceleratedCryptographicHash::impl {
0))) 0)))
{ {
qDebug() << "BCryptFinishHash returned Error " << status; qDebug() << "BCryptFinishHash returned Error " << status;
cleanup() cleanup();
return {}; return {};
} else { } else {
// No cleanup required, as the dtor of this class will do so. // No cleanup required, as the dtor of this class will do so.