CID#18499 Resource leak

Error handling could lead to a resource leak of
the struct pointed by task if allocation of mul
failed. The fix is a bit longer than the previous
version but it's more readable and avoids a
resource leak.