Skip to content

Commit

Permalink
Fix COSIndirect casts to COSDirect descendants (#659)
Browse files Browse the repository at this point in the history
* Fix COSIndirect to COSArray casts

* Fix COSIndirect to COSName casts
  • Loading branch information
e-zhavoronok authored Feb 25, 2025
1 parent de7ccd7 commit 347ae53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/verapdf/parser/postscript/PSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public static PSObject getPSObject(COSObject obj, boolean isExecutable) {
}
COSObjType type = obj.getType();
if (type == COSObjType.COS_NAME && isExecutable) {
return new PSOperator((COSName) obj.get());
return new PSOperator((COSName) obj.getDirectBase());
} else if (type == COSObjType.COS_ARRAY && isExecutable) {
return new PSProcedure((COSArray) obj.get());
return new PSProcedure((COSArray) obj.getDirectBase());
} else if (type.isNumber() || type == COSObjType.COS_STRING ||
type == COSObjType.COS_BOOLEAN || type == COSObjType.COS_DICT ||
type == COSObjType.COS_NAME || type == COSObjType.COS_ARRAY) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/verapdf/pd/font/type1/Type1FontProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private double[] getFontMatrix() {
if (fontMatrixObject != null && fontMatrixObject.getType() == COSObjType.COS_ARRAY) {
double[] res = new double[6];
int pointer = 0;
for (COSObject obj : ((COSArray) fontMatrixObject.get())) {
for (COSObject obj : ((COSArray) fontMatrixObject.getDirectBase())) {
if (obj.getType().isNumber()) {
res[pointer++] = obj.getReal();
}
Expand All @@ -297,7 +297,7 @@ private void initializeEncoding() {
if (encoding != null) {
if (encoding.getType() == COSObjType.COS_ARRAY) {
int pointer = 0;
for (COSObject obj : ((COSArray) encoding.get())) {
for (COSObject obj : ((COSArray) encoding.getDirectBase())) {
if (pointer < 256) {
String glyphName = obj.getString();
this.encoding[pointer++] = glyphName == null ? "" : glyphName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public List<PDNumberTreeNode> parseKids() {
COSObject kids = this.getKey(ASAtom.KIDS);
if (kids != null && !kids.empty() && kids.getType() == COSObjType.COS_ARRAY) {
List<PDNumberTreeNode> res = new ArrayList<>(kids.size());
for (COSObject obj : (COSArray) kids.get()) {
for (COSObject obj : (COSArray) kids.getDirectBase()) {
res.add(new PDNumberTreeNode(obj, parents));
}
return Collections.unmodifiableList(res);
Expand Down

0 comments on commit 347ae53

Please sign in to comment.