ParseSizeString - don't abort on unknown unit type.

pull/1428/head
Jason Ish 12 years ago
parent 00d6298666
commit ca60d8c370

@ -125,8 +125,9 @@ static int ParseSizeString(const char *size, double *res)
} else if (strcasecmp(str2, "gb") == 0) {
*res *= 1024 * 1024 * 1024;
} else {
/* not possible */
BUG_ON(1);
/* Bad unit. */
retval = -1;
goto end;
}
}
@ -1118,6 +1119,11 @@ int UtilMiscParseSizeStringTest01(void)
goto error;
}
/* Should fail on unknown units. */
if (ParseSizeString("32eb", &result) > 0) {
goto error;
}
return 1;
error:
return 0;

Loading…
Cancel
Save