优化异常判断逻辑

hdrplus
Matthew 11 months ago
parent 6308331462
commit 56d01ac2ff

@ -121,7 +121,7 @@ Java_com_xypower_mpmaster_MpMasterService_getStats(JNIEnv* env, jclass cls, jlon
MP_STATS stats = { 0 };
size_t length = fread(&stats, 1, sizeof(stats), file);
fclose(file);
if (length != sizeof(stats))
if (length < sizeof(stats))
{
return NULL;
}
@ -130,7 +130,6 @@ Java_com_xypower_mpmaster_MpMasterService_getStats(JNIEnv* env, jclass cls, jlon
jintArray result = env->NewIntArray(intLength);
env->SetIntArrayRegion(result, 0, intLength, (const jint*)&stats);
return result;
}

Loading…
Cancel
Save